示例代码:
try {
File f = new File("d:\\test.txt");
//OutputStreamWriter out = new OutputStreamWriter(new FileOutputStream(file,true),"UTF-16LE");
BufferedReader reader=new BufferedReader( new InputStreamReader(new FileInputStream("D:\\read.srt"),"GBK"));
//x-UTF-16LE-BOM UTF-16LE
OutputStreamWriter writer = new OutputStreamWriter(new FileOutputStream("D:\\write.srt"),"x-UTF-16LE-BOM");
int temp=0;
while ((temp = reader.read()) != -1) {
System.out.println(temp);
writer.write(temp);
}
reader.close();
writer.flush();
writer.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
}