import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.UnsupportedEncodingException;
public class Demo8_TransIO {
/**
* @param args
* 转换流
* @throws IOException
* 字符流(字节流+编码表)
* 读gbk编码表的文件写到utf-8编码表文件
* 高效
*/
public static void main(String[] args) throws IOException {
//demo1();
//demo2();
//demo3();
//demo4();
BufferedReader br =
new BufferedReader(new InputStreamReader(new FileInputStream("day22笔记.txt"),"gbk"));
BufferedWriter bw =
new BufferedWriter(new OutputStreamWriter(new FileOutputStream("UTF-8.txt"),"UTF-8"));
int ch;
while((ch = br.read()) != -1) {
bw.write(ch);
}
br.close();
bw.close();
}
} |
|