A
Angus
Hello
I have code a bit like this:
BufferedReader bis = new BufferedReader(new
InputStreamReader(tserverSocket.getInputStream()));
// Here I write some data - getting a response - some lines of text returned
boolean more = true;
while(more)
{
String line = bis.readLine();
if (line == null)
more = false;
else
System.out.println(line);
}
But code never gets out of while loop.
I assumed when there was no more input it would return null, so more would
be set to false and it would exit loop.
I want to test for a carriage return. (I know text is in ASCII format, and
I know end of each line has a carriange return and line feed.
So I tried doing this:
if (line.indexOf("\n") != -1)
{
break;
}
But it didn't seem to find \n . How should I test for a carriage return?
Angus
I have code a bit like this:
BufferedReader bis = new BufferedReader(new
InputStreamReader(tserverSocket.getInputStream()));
// Here I write some data - getting a response - some lines of text returned
boolean more = true;
while(more)
{
String line = bis.readLine();
if (line == null)
more = false;
else
System.out.println(line);
}
But code never gets out of while loop.
I assumed when there was no more input it would return null, so more would
be set to false and it would exit loop.
I want to test for a carriage return. (I know text is in ASCII format, and
I know end of each line has a carriange return and line feed.
So I tried doing this:
if (line.indexOf("\n") != -1)
{
break;
}
But it didn't seem to find \n . How should I test for a carriage return?
Angus