Answer the question
In order to leave comments, you need to log in
Why does in.read() wait indefinitely?
Socket socket = new Socket("localhost",2019);
InputStreamReader in = new InputStreamReader(socket.getInputStream());
char a;
String str = "";
while ((a= (char) in.read()) != -1){
str += a;
}
Answer the question
In order to leave comments, you need to log in
char is an unsigned number and therefore will never equal -1.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question