//用RandomAccessFile读取出来乱码的解决
String path = "d:/test.txt";
RandomAccessFile raf = null;
String line = null;
try {
raf = new RandomAccessFile(path, "rw");
while ((line = raf.readLine()) != null) {
line = new String(line.getBytes("8859_1"), "gb2312");//转变编码格式
System.out.println(line);
}
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
raf.close();
} catch (IOException e) {
e.printStackTrace();
}
}
//用RandomAccessFile写入文件乱码的解决
raf.write(str.getBytes());