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
2010-10-01 19:09:33
in java thank youd
Luron
2010-10-01 19:16:46
is there anything more efficient tho. like i dont want it to search one byte at a time
Luron
2010-10-01 19:19:59
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
2010-10-01 19:25:31
+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
2010-10-01 19:26:00