package com.lovecoding.day22.io02;

import org.junit.Test;

import java.io.*;

public class TestChangeIo {

    //把今天的作业文件夹下的《我想对你说.txt》字符编码为GBK，复制到当前项目的testIO文件夹下的《陈老师的话.txt》字符编码为UTF-8。
    @Test
    public void test02() throws  Exception{
        //编码问题 转换流 构造里面可以制定 编码
        //GBK 中文站2个字节
        InputStreamReader isr = new InputStreamReader( new FileInputStream("aa.txt"),"GBK");
        //缓冲包裹
        BufferedReader br = new BufferedReader(isr);
        //输出
        OutputStreamWriter osw = new OutputStreamWriter(new FileOutputStream("d.txt"),"UTF-8");

        String s = br.readLine();
        System.out.println(s);

        //写出
        osw.write(s);
        osw.close();
        br.close();
        isr.close();
    }

    @Test
    public void test01() throws  Exception{
        //编码问题 转换流 构造里面可以制定 编码
        //GBK 中文站2个字节
        InputStreamReader isr = new InputStreamReader( new FileInputStream("a.txt"),"GBK");
        //缓冲包裹
        BufferedReader br = new BufferedReader(isr);

        String s = br.readLine();
        System.out.println(s);

    }
}
