[問題] InputStreamReader

看板java作者 (真呆)時間18年前 (2008/02/04 15:46), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串1/6 (看更多)
想請教各位大大,我想寫一個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
文章代碼(AID): #17fiBprp (java)
文章代碼(AID): #17fiBprp (java)