我试图读取输入单词,但无法弄清楚如何将扫描仪的分隔符设置为空白和标点符号除'(单引号)。 这是我得到的扫描仪的分隔符和正则表达式在java
BufferedReader input;
String line;
Scanner sc;
String word;
try {
input = new BufferedReader(new FileReader(path));
while (input.ready()) {
line = input.readLine();
System.out.println("Current Line: " + line);
sc = new Scanner(line);
sc.useDelimiter("\\W\\s^\'");
//...
}
}
//...
'String line = sc.nextLine(); ''String [] words = line.split(“”); ' – run 2012-02-17 08:47:58
@run和标点符号怎么样? – 2012-02-17 08:50:59
是的,我的代码与此类似。 – 0x56794E 2012-02-17 08:58:25