[問題] Socket的DataInputStream
請問一下,如果是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/07 06:37, 1F
→
05/08 00:00, , 2F
05/08 00:00, 2F