Java tutorial
//package com.java2s; import java.util.Scanner; import java.util.regex.Pattern; public class Main { private static final Pattern WHITESPACE_PATTERN = Pattern.compile("\\s+"); private static Scanner wordScanner(String text) { Scanner s = new Scanner(text); s.useDelimiter(WHITESPACE_PATTERN); return s; } }