大神帮我看一下为什么我buf.readLine()会出错

客户端代码:
public void onClick(View v) {
// TODO Auto-generated method stub

new Thread(){
public void run(){
try {
client=new Socket("192.168.1.101",8080);
 PrintStream out=new PrintStream(client.getOutputStream());
BufferedReader buf=new BufferedReader(new InputStreamReader(client.getInputStream()));
String s=ed.getText().toString();
out.println(s);
String s1=buf.readLine();
buf.close();
out.close();
client.close();
//txt.setText(s1);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}.start();
}
服务器端代码:
public server(Socket client){
this.client=client;
}
@Override
public void run() {
// TODO Auto-generated method stub
boolean f=true;
try {

boolean bo=true;

PrintStream p=new PrintStream(client.getOutputStream());

BufferedReader buf=new BufferedReader(new InputStreamReader(client.getInputStream()));

String s=buf.readLine();
System.out.println("客户端打"+new String(s.getBytes("iso-8859-1"),"utf-8"));


buf.close();
p.close();
client.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}

你可能感兴趣的:(大神帮我看一下为什么我buf.readLine()会出错)