I started taking a look at some of the new classes in Java5 but i am a bit confused on how a Scanner uses delimiters. For instance take the following block of code.
What is the "\\s*" used for? If the delimiter wasCode:String input = "1 fish 2 fish red fish blue fish"; Scanner s = new Scanner(input).useDelimiter("\\s*fish\\s*"); System.out.println(s.nextInt()); System.out.println(s.nextInt()); System.out.println(s.next()); System.out.println(s.next()); s.close();
specified as useDelimiter("fish"); wouldn't the output
still be the same?




Reply With Quote