【发布时间】:2017-04-01 12:59:48
【问题描述】:
我有一个扫描程序类将文件读入字符串。任何带有此字符“®”的文件都会导致它失败。我是 Java 新手,有没有更好的方法来读取此文件以便接受该字符?
public void readFile(String fileName)
{
fileText = "";
try
{
Scanner file = new Scanner(new File(fileName));
while (file.hasNextLine())
{
String line = file.nextLine();
fileText += line +"\r"+"\n";
}
file.close();
}
catch (Exception e)
{
System.out.println(e);
}
}
【问题讨论】:
-
它会抛出什么错误?
-
如果可能的话,你能不能使用 hexdump -C 把包含 (R) 字符的文件的一小部分...
-
“任何带有这个字符“®”的文件都会导致它失败。”你怎么知道?