Testing invisible characters in java

I am writing a Java program that validates several FTP commands. These commands should be in carriage return and in a new line (sequence "\ r \ n"). I am using BufferedReader to read in lines, but I cannot find a way to check if a line ends in this sequence. Any ideas?

+4
source share
1 answer

Do not use BufferedReader because the level of abstraction seems too high for your specific tasks. Use regular InputStream and read into byte array. An InputStream will read all bytes as is. You can process them, and later create lines yourself, using a new line (array, offset, length) . It could possibly be other invalid characters, such as 0x0C at the input.

0
source

All Articles