【发布时间】:2020-10-21 21:26:33
【问题描述】:
我之前已经成功使用过 ISO8859-13 字符编码,但这次似乎不起作用。
基于网站https://en.wikipedia.org/wiki/ISO/IEC_8859-13,它是一个有效字符。
这些是存储在文件中的 3 个字符。 啊啊啊
这是正在使用的代码。
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
public class ReadFile
{
public static void main(String[] arguments)
{
try
{
File inFile = new File("C:\\Downloads\\MyFile.txt");
if (inFile.exists())
{
System.out.println("File found");
BufferedReader in = new BufferedReader(
new InputStreamReader(new FileInputStream(inFile), "ISO8859-13"));
String line = null;
while ( (line = in.readLine()) != null )
{
System.out.println("Line Read: >" + line + "<");
}
}
else
{
System.out.println("File not found");
}
}
catch (IOException e)
{
}
}
}
在使用和/或不使用 Eclipse 的 Windows 和 Linux 上的输出是相同的。
Line Read: >?¤?¤?¤<
这以前适用于许多其他角色,但为什么不适用呢?
【问题讨论】:
标签: java unicode file-io character