catch(IOException e) {
System.err.println("連接失敗");
System.exit(1);
}
byte[] inArray = new byte[10];
byte[] outArray = new byte[20];
int bytesRead = 0;
try {
// 向pipedOS發送20字節數據
pipedOS.write(outArray, 0, 20);
System.out.println(" 已發送20字節...");
// 在每一次循環迭代中,讀入10字節
// 發送20字節
bytesRead = pipedIS.read(inArray, 0, 10);
int i=0;
while(bytesRead != -1) {
pipedOS.write(outArray, 0, 20);
System.out.println(" 已發送20字節..."+i);
i++;
bytesRead = pipedIS.read(inArray, 0, 10);
}
}
延伸閱讀
文章來源于領測軟件測試網 http://www.kjueaiud.com/