标签:读取 ade tput NPU pre 输入 flush tst writer
/**
*
* 请将下面文件保存成 琵琶行_GBK.txt
* 浔阳江头夜送客,
* 枫叶荻花秋瑟瑟。
* 主人下马客在船,
* 举酒欲饮无管弦。
* 醉不成欢惨将别,
* 别时茫茫江浸月。
* 再将文件转换成 琵琶行_UTF-8.txt
*
*/
public class PiPaXing2 {
public static void main(String[] args) throws IOException {
OutputStreamWriter ooss = new OutputStreamWriter(new FileOutputStream("琵琶行_GBK.txt"),"GBK");
ooss.write("浔阳江头夜送客,\r\n");
ooss.write("枫叶荻花秋瑟瑟。\r\n");
ooss.write("主人下马客在船,\r\n");
ooss.write("举酒欲饮无管弦。\r\n");
ooss.write("醉不成欢惨将别,\r\n");
ooss.write("别时茫茫江浸月。\r\n");
ooss.close();
//创建文件输入流对象,把gbk文件读取到计算机
InputStreamReader isr = new InputStreamReader(new FileInputStream("琵琶行_GBK.txt"),"GBK");//读取文件
//创建文件输出流对
OutputStreamWriter osw = new OutputStreamWriter(new FileOutputStream("琵琶行_UTF-8.txt"),"UTF8");
int len;
while((len = isr.read()) != -1){
osw.write(len);
// System.out.println(len);
}
osw.flush();
osw.close();
isr.close();
System.out.println("写入完成");
}
}
标签:读取 ade tput NPU pre 输入 flush tst writer
原文地址:https://www.cnblogs.com/YRSWBY2016/p/12019482.html