views:

48

answers:

3

I need to scan an input file and search for a specific value. How do I do that?

A: 

what language?

in java: http://download.oracle.com/javase/tutorial/essential/io/bytestreams.html

saadshakil
in java thank youd
Luron
is there anything more efficient tho. like i dont want it to search one byte at a time
Luron
A: 

http://download.oracle.com/javase/1.5.0/docs/api/java/util/Scanner.html

You can do nextInt() if you are looking for ints and so on.

mezzie
+1  A: 

You could open a Scanner on a File, and with a Scanner.findWithinHorizon() you can search the very next occurrence of your research.

For example :

File file = new File("/Users/me/file.txt");
Scanner scanner = new Scanner(file);
String foundString = scanner.findWithinHorizon("hello", 0); //You can replace Hello with a regex if you want.

Resources :

Colin Hebert