try {
// 把提取到的數據發送給PipedOutputStream
pipedOS.write(buffer, 0, buffer.length);
}
catch(IOException e) {
// 記錄錯誤或其他處理
// 為簡單計,此處我們直接結束
System.exit(1);
}
}
else // 沒有數據可用,線程進入睡眠狀態
try {
// 每隔1秒查看ByteArrayOutputStream檢查新數據
Thread.sleep(1000);
}
catch(InterruptedException e) {}
}
}
}).start();
} // startByteArrayReaderThread()
} // LoopedStreams
文章來源于領測軟件測試網 http://www.kjueaiud.com/