|
| ||
Chiggins(devpen) (crs) (badass)
(moderator) HTML/CSS & NeoHome Help ![]() total posts: 2499 neopoints: 204 GameGrep pts: 613 since: Jun 2003 |
[Java] Looping Through A File | |
|
Alright, I'm using the Scanner class to run through some information inside a text file. The text file is as follows (the "arrows" show the end of each entry):
quoteAs you see, they entries can be of various length. How could I create a loop to go through each one of those entries? ------------------- | ||
quote quick quote edit quick edit del posts in thread report
| ||
Liam
|
re: [Java] Looping Through A File | |
|
If they can be of various length and spanned over various lines then it's near on impossible to automate identifying individual entries. The input will require something to specify where a new entry begins, whether its a unique character or pattern.
| ||
quote quick quote edit quick edit del posts in thread report
| ||
Chiggins(devpen) (crs) (badass)
(moderator) HTML/CSS & NeoHome Help ![]() total posts: 2499 neopoints: 204 GameGrep pts: 613 since: Jun 2003 |
re: [Java] Looping Through A File | |
|
I was able to figure this out. inputFile is the Scanner of the file being read, and person is the Person class to where the information is being read from.
Since the first two lines of each entry in the text file will always be there, we look at those. If the second one reads UNKNOWN, we stop, because we don't know the persons address. If we do know it, we continue to read until the end of the address.
------------------- | ||
quote quick quote edit quick edit del posts in thread report
| ||
| [All dates in (PT) time] | Threads List « Next Newest Next Oldest » | |
Powered by neoforums v0.9.8b (equilibrium)
Copyright Neo Era Media, Inc. 1999-2009