java 读取文本文件的乱码问题???
void readFile(String path) // 显示打开文件的内容
{
try
{
File file = new File(path);
BufferedReader br = new BufferedReader(new InputStreamReader(
new FileInputStream(file), "GBK"));// 编码转换
int size = (int) file.length();
int charRead = 0;
char[] content = new char[size];
while (br.ready())
{
charRead += br.read(content, charRead, size - charRead);
}
br.close();
text.setText(new String(content, 0, charRead));
} catch (IOException e)
{
System.out.println("读取文件出错");
}
}