< prev index next >

src/java.base/share/classes/java/util/Scanner.java

Print this page

        

*** 2895,2905 **** * For example, the following code will read a file and return a list * of all sequences of characters consisting of seven or more Latin capital * letters: * * <pre>{@code ! * try (Scanner sc = new Scanner(Paths.get("input.txt"))) { * Pattern pat = Pattern.compile("[A-Z]{7,}"); * List<String> capWords = sc.findAll(pat) * .map(MatchResult::group) * .collect(Collectors.toList()); * } --- 2895,2905 ---- * For example, the following code will read a file and return a list * of all sequences of characters consisting of seven or more Latin capital * letters: * * <pre>{@code ! * try (Scanner sc = new Scanner(Path.get("input.txt"))) { * Pattern pat = Pattern.compile("[A-Z]{7,}"); * List<String> capWords = sc.findAll(pat) * .map(MatchResult::group) * .collect(Collectors.toList()); * }
< prev index next >