Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Scanner Question (Line Problem)

 
Rob Mech
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hopefully this is a no-brainer for somone. I have some data that I'd prefer to read in with the Scanner class. I have to break up this data and scanner works perfectly for it.

My problem is that the data contains no CRLF (or any other line break character).

For example:

ABCD123~ABC484848~23423423~

That might be an example line however it's HUGE (2-3 MB files). When I input this into the scanner and just use the ~ as a delimiter it runs out of Heap space.

I'd like to gracefully parse through this preferably using "next".

I've thought about just using a more "low level" read and replacing the ~ with a ~(CRLF) and then re-opening the stream but I'd prefer to make it more efficient.

Suggestions?
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Show how you used Scanner with a little code. Running out of heap makes me think you tried to read the whole thing at once somehow.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic