问题
I am currently trying to read a String from a BufferedReader but cant find a way to do this...
Of course I tried
BufferedReader inStream = null;
inStream = new BufferedReader(new InputStreamReader(client.getInputStream()));
String test = inStream.readLine();
However the result turns out as null when trying to print to a screen even though the BufferedReader inStream is equal to some kind of message.
回答1:
Based on the documentation, the BufferedReader.readLine() returns null only when the end of the stream is reached. This means if the first call to readLine() returns null, there was nothing in the input stream to begin with.
来源:https://stackoverflow.com/questions/10202515/reading-from-a-bufferedreader-readline-returns-null