According to javadoc for java.util.Scanner.skip
, this method:
Skips input matching pattern specified, ignoring delimiters .
But I'm confused by what the phrase “ignore delimiters” means, because the following code throws an exception using Java 7 in Eclipse:
import java.util.Scanner; public class Example { public static void main(String [] args) { Scanner sc = new Scanner("Hello World! Here 55"); String piece = sc.next(); sc.skip("World");
It does not ignore delimiters when skipping, as shown in Line A. However, Line C works, although its documentation uses the same phrase “ignore delimiters”. Do I really not understand their concept of "ignoring separators" in this case, or is this a real mistake? What am I missing?
source share