java程序测试之字符流

package filestream;

import java.io.FileReader;
import java.io.FileWriter;
import java.io.FileNotFoundException;
import java.io.IOException;

public class CharacterStreamTester {

    public static void main(String [] args)
    {
        FileReader in = null;
        FileWriter out = null;
        String path = "E:\\java\\";
        try
        {
            in = new FileReader(path+"IOFile.txt");
            out = new FileWriter(path+"IOFile_copy.txt");
            int c;
            while((c=in.read())!=-1)
            {
                out.write(c);
            }
        }
        catch(FileNotFoundException e)
        {
            e.printStackTrace();
        }
        
        catch(IOException e)
        {
            e.printStackTrace();
        }
        finally
        {
            try
            {
                if (in!=null)
                {
                    in.close();
                }
                if(out!=null)
                {
                    out.close();
                }
            }
            catch(IOException e)
            {
                e.printStackTrace();
            }
        }
    }
}
原文地址:https://www.cnblogs.com/ghmgm/p/4354780.html