RandomAccessFile 文件读写中文乱码解决方案!
时间:2021-07-01 10:21:17
帮助过:2人阅读
fileReadAndWrite;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.RandomAccessFile;
/**
* 测试文件读写
* @author laobiao
*
*/
public class bigFileRW {
public static void main(String[] args)
throws Exception {
RandomAccessFile ra =
new RandomAccessFile("test.txt", "rw"
);
ra.seek(0
);
ra.write("a bcd你好啊的撒法"
.getBytes());
ra.seek(0
);
System.out.println(new String(ra.readLine().getBytes("ISO-8859-1"),"utf-8"));
//需要重新转码才能正常显示
ra.close();
}
}
RandomAccessFile 文件读写中文乱码解决方案!
标签: