Wednesday, February 19, 2014
socket problem, friends to help look
public String recvMsg () {
byte [] b = null;
try {
in = sockClient.getInputStream ();
b = new byte [in.available ()];
in.read (b);
} Catch (IOException e) {
/ / TODO Auto-generated catch block
e.printStackTrace ();
}
return b.toString ();
}
How can I ask a question right approach<-! Main posts under Banner (D4) -><-! Posts under the main text (D5) ->
Reply:
in = sockClient.getInputStream ();
b = new byte [in.available ()];
in.read (b);
Write stream may not be able to read, you need to read the stream
circulationint i = -1;
while ((i = in.read (b))! = -1) {
/ / Write to the buffer, you can use ByteArrayOutputStream
}
Reply:
in.read (b) has a similar iterator function, was read to reading cycle
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment