package com.itheima.exam1.io;
import java.io.*;
public class InputStreamReaderDemo
{
/**
* @throws IOException
* @param args
* @throws
*/
public static void main(String[] args) throws IOException
{ //读取一个UTF_8的文件
InputStreamReader in = new InputStreamReader(new FileInputStream(
"D:\\2.txt"), "UTF-8");
//以GBK存储文件
OutputStreamWriter buffw = new OutputStreamWriter(new FileOutputStream(
"D:\\5.txt"), "gbk");
char[] buf = new char[1024];
int len = 0;
while ((len = in.read(buf)) != -1)
{
buffw.write(buf,0,len);
buffw.flush();
}
in.close();
buffw.close();
}
}
|
UTF-8转GBK--->小试
最新推荐文章于 2023-11-03 23:22:14 发布