编码转换

package com.itcast;

import java.io.*;

/**
* @author newcityman
* @date 2019/7/28 - 22:16
* 练习:转换文件编码
* 将GBK编码的文本文件,转换成UTF-8编码的文件
*/
public class demo06Test {
public static void main(String[] args) throws IOException {
InputStreamReader isr = new InputStreamReader(new FileInputStream("day18_IOAndProperties\我是GBK格式的文件.txt"),"gbk");
OutputStreamWriter osr = new OutputStreamWriter(new FileOutputStream("day18_IOAndProperties\我是UTF_8格式的文件.txt"),"utf-8");
int len;
while((len=isr.read())!=-1){
osr.write(len);
}
osr.close();
isr.close();
}
}
原文地址:https://www.cnblogs.com/newcityboy/p/11261244.html