try { dis=new DataInputStream(new BufferedInputStream(socket.getInputStream())); dos=new DataOutputStream(new BufferedOutputStream(socket.getOutputStream())); } catch (IOException e) { e.printStackTrace(); }
BufferedReader in = new BufferedReader(new InputStreamReader(socket.getInputStream()));其中getInputStream()方法返回socket类字节流,在通过InputStreamReader将其转化为字符流并通过BufferedReader对其封装,之后就可以使用BufferedReader提供的方法readLine一行一行地读入字符串。
版权声明:本文为博主原创文章,未经博主允许不得转载。
原文地址:http://blog.csdn.net/liuruiqun/article/details/47106169