Scanner scanner = new Scanner(System.in);
scanner.useDelimiter("\\s*,\\s*"); // 使用逗号作为分隔符
while (scanner.hasNext()) {
String input = scanner.next();
System.out.println(input);
}
try (Scanner scanner = new Scanner(new File("input.txt"))) {
while (scanner.hasNext()) {
String input = scanner.next();
System.out.println(input);
}
} catch (FileNotFoundException e) {
e.printStackTrace();
}
Scanner scanner = new Scanner(System.in);
scanner.useDelimiter(Pattern.compile("[,.;\\s]+"));
while (scanner.hasNext()) {
String input = scanner.next();
System.out.println(input);
}
Scanner scanner = new Scanner(System.in);
while (scanner.hasNextLine()) {
String line = scanner.nextLine();
System.out.println(line);
}
Scanner scanner = new Scanner(System.in);
int intValue = scanner.nextInt();
double doubleValue = scanner.nextDouble();
String stringValue = scanner.next();