PDA

View Full Version : A way to make a global FileReader/Scanner?



WhiteShadow
03-02-2011, 07:48 PM
Hey,

Does anyone know a way to make a 'global' scanner & filereader?

I'm trying to make a program that reads a file and uses the input to do stuff but the problem is different parts of the program need different parts of the file so I want to be able to use scanner.next() in one part of the program and then skip a couple lines and have the other part of the file use the nextInt() or something. You know like not just restricted to one main loop or anything.

And I'm not allowed to parse everything at once and save it in a ArrayList<String> or anything. :(

Thanks,

WhiteShadow

Iamadam
03-02-2011, 11:00 PM
Will you be reading the file in order, or do you need to skip around?
Not entirely sure what you need, but I'll help you out when I know :)

Is the task to make a Scanner type class? Or just to use the existing Scanner?

johnpitter
03-14-2011, 04:56 AM
Basic work of Scanner class is that, Objects of type Scanner are useful for decomposing formatted input into tokens and translating individual tokens according to their data type.