I'm writing a program in Java that tests the validity of several FTP commands. These commands must in a a carriage return and new line feed (the sequence "\r\n"). I'm using a BufferedReader to read in lines, but I cannot come up with a way to check if the line ends in this sequence. Any ideas?
Asked
Active
Viewed 191 times
4
-
5http://stackoverflow.com/questions/6113435/how-to-find-out-which-line-separator-bufferedreaderreadline-used-to-split-the – Anirudh Ramanathan Jan 20 '13 at 21:06
-
1What have you tired? Show us your code. – MrSmith42 Jan 20 '13 at 21:06
-
2If you want to check the exact sequence of CRLF you will need to read one char at a time. – Peter Lawrey Jan 20 '13 at 21:13
1 Answers
0
Do not use the BufferedReader
because abstraction level seems too high for your specific tasks. Use the ordinary InputStream, and read into byte array. InputStream will read all bytes as they are. You can process them and later produce strings yourself later using new String(array, offset, length). Maybe it can be other invalid characters like 0x0C in the input.

Audrius Meškauskas
- 20,936
- 12
- 75
- 93