特殊字符扫描仪Java

时间:2014-07-02 13:10:30

标签: java special-characters java.util.scanner

如何使用java Scanner类从文件中读取特殊字符?我尝试过提及但不起作用。

Scanner scanner = new Scanner(new File("words.txt"), "utf-8");
Scanner lineScanner = null;
while (scanner.hasNextLine()) {
    lineScanner = new Scanner(scanner.nextLine());
    lineScanner.useDelimiter(";");
    String article = lineScanner.next();
    // and so on...
}
// Close the scanners 

我想读的是这样的一行:

"la;leçon;de les;lesòn"

1 个答案:

答案 0 :(得分:0)

字符编码不正确。法语应该是iso-8859-1。