input in this example is a String. Is there a way to do the same thing with a file? I haven't been able to construct it. Or do I have to read the whole file first and store it in a string?Code: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();
----
also in the above example the parameter passed to useDelimiter(), what's \\s* for? whitespace?