• Post Reply Bookmark Topic Watch Topic
  • New Topic

Changing the EOL value in BufferedReader()  RSS feed

 
Jim Venolia
Ranch Hand
Posts: 312
2
Chrome Linux VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My input data is an ASCII text file consisting of records, contained in 1 to n lines where n really has no defined upper limit (but in practice is maybe 40 and is typically 2-5). Each record is separated by a blank line. For example



In perl it's easy to change the EOL value the read routines use, so a single readLine() returns the entire record (haven't done this for a few years, my perl is rusty so forgive the syntax).

Is it possible to change BufferReader()'s EOL so I can slurp up an entire record with 1 read? Note I'm not concerned with \n, \r, or \n\r issues (which are what google keeps giving me). I want my EOL to be ^$.

I've currently got a 38 line routine that works, but it would be much cleaner to change the EOL value.
 
Stephan van Hulst
Saloon Keeper
Posts: 7993
143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I wouldn't say it became cleaner, because you're changing the meaning of line to no longer be a line.

However, you can probably do what you want using java.util.Scanner instead. Have a look at the documentation.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!