2014-09-24 60 views
0

我在客户端服务器android应用程序上工作在这里我的客户端是我的应用程序。我通过无线路由器将字符串发送到服务器。字符串的发送工作正常,但我没有得到如何处理来自服务器的响应字符串。 这里是我的发送在套接字编程中接收字符串android

PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(socket.getOutputStream())),true); 
out.println(str); 

回答

0

试试这个

InputStream is=socket.getInputStream(); 
int ch; 
StringBuffer sb=new StringBuffer(); 
while((ch=(is.read))!=-1) 
{ 
    byte b=(byte)ch; 
    sb.append(b); 
} 
String response=sb.toString(); 
发送和接收字符串

代码