mert said:
Hi eveyone, :twisted:
I have a problem about Scanner class which make me really annoyed.
I could not find the meaning of useDelimiter()
method.Besides,
I do not understand why it is used and when.
If anyone inform me , I will be happy.
Thanks
Mert
http://www.devplug.com
You can change the delimiter that is used to tokenize the input,
through the useDelimiter method of Scanner. You can pass in a String or
a java.util.regex.Pattern to the method. See the JavaDocs page for
Pattern for information on what patterns are appropriate. For example,
you can read the input one line at a time by using the newline character
(\n) as a delimiter. Here is a readFile() method that uses a newline
character as the delimiter:
private static void readFile(String fileName) {
try {
Scanner scanner = new Scanner(new File(fileName));
scanner.useDelimiter(System.getProperty("line.separator"));
while (scanner.hasNext()) {
System.out.println(scanner.next());
scanner.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
}
}
--
Thanks in Advance...
IchBin, Pocono Lake, Pa, USA
http://weconsultants.servebeer.com/JHackerAppManager
__________________________________________________________________________
'If there is one, Knowledge is the "Fountain of Youth"'
-William E. Taylor, Regular Guy (1952-)