A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Win a copy of
Elasticsearch in Action
this week in the
Scanner Question (Line Problem)
Joined: Apr 05, 2007
Jul 20, 2007 07:26:00
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).
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.
Rob Mech, SCJP 1.5<br /><a href="http://www.robsprogrammingjunk.com/" target="_blank" rel="nofollow">http://www.robsprogrammingjunk.com/</a>
Joined: Jan 29, 2003
Jul 22, 2007 12:07:00
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.
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
I agree. Here's the link:
subject: Scanner Question (Line Problem)
Get pathname to data file
How to set width of cells in excel on browser ?
cell formatting in excel using jsp
Study Material for Scanner and Fromatter
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2015