javaserversocketjava-server

What to use instead of BufferedReader for server


I was told that BufferedReader.readLine() is not a suitable method to read data from clientSocket, because it consideres a line as a String ending with \n or \r. However, my ending symbol for line is \r\n. What should I use insted of buffered reader?


Solution

  • I was told that BufferedReader.readLine() is not a suitable method to read data from clientSocket, because it consideres a line as a String ending with \n or \r.

    You were told wrong. See the Javadoc.

    However, my ending symbol for line is \r\n. What should I use insted of buffered reader?

    You don't need anything instead of BufferedReader. It will recognize that as a line terminator. See the Javadoc.

    ... if I get a line with \r or \n inside

    There is no such thing.