[問題] Socket的DataInputStream

看板java作者 (我是清流)時間11年前 (2013/05/07 00:57), 編輯推噓1(101)
留言2則, 2人參與, 最新討論串1/1
請問一下,如果是Server端 用Socket接收到的DataInputStream,要如何丟到String裡 我有查網路資料是用 dis.readLine,但Eclipse說已經Deprecated了 也有查到是用 byte input[]=new byte[dis.available()]; dis.readFully(input); 但我試的結果是失敗,input結果是空的 我的書上的範例是用dis.readByte() 但一個字一個字讀好像沒有必要(書上的Client是用Telnet登入連Server) Client端我是用以下方式丟字串 OutputStream os=socket.getOutputStream(); os.write(new String(namestr).getBytes()); -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 36.231.136.75

05/07 06:37, , 1F

05/08 00:00, , 2F
成功了,謝謝樓上大大
05/08 00:00, 2F
文章代碼(AID): #1HX-42ze (java)