dealing with extra carriage returns

S

sky_diver_

I use BufferedReader.readLine to process customer's text files.
Occasionally, I get files that terminate each line with CR+CR+LF (two
carriage returns and a linefeed). Every text editor I use treats this a
valid line terminater and displays it as a single line, but the
BufferedReader.readLine method sees each line as two lines.

Would wrapping an InputStreamReader within the BufferedReader be the
best way to get around this problem?
 
S

Steve Horsley

I use BufferedReader.readLine to process customer's text files.
Occasionally, I get files that terminate each line with CR+CR+LF (two
carriage returns and a linefeed). Every text editor I use treats this a
valid line terminater and displays it as a single line, but the
BufferedReader.readLine method sees each line as two lines.

Would wrapping an InputStreamReader within the BufferedReader be the
best way to get around this problem?

If you know there shouldn't be blank lines, the easiest thing
would be to ignore them. But if you cannot tell, I think you will
have to go 'under' the reader and look directly at the raw data
- read from the InputStream, perhaps making a custom
FilterInputStream that you can wrap with an InputStreamReader.

Steve
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,150
Latest member
MakersCBDReviews
Top