想請教各位大大,我想寫一個server的程式(使用socket)
部分code如下:
InputStreamReader in=new InputStreamReader(connection.getInputStream());
int ch = 0;
String msg="";
do{
while((ch=in.read())!=-1){
msg+=(char)ch;
}
System.out.println(msg);
}while(!msg.equals("quit"));
想印出從client接收到的文字,但若用上面寫法都印不出來,
除非把msg+=(char)ch;改成System.out.print((char)ch);
這樣才能印出來,請問是為什麼呢???
謝謝了!
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 219.87.151.40