SRL Archive - Java Help and Tutorials

A way to make a global FileReader/Scanner?


WhiteShadow

2011-03-02 14:48:16

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

2011-03-02 18:00:19

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

2011-03-14 00:56:29

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.