zoukankan      html  css  js  c++  java
  • java程序测试之字节流

    package filestream;
    
    import java.io.FileInputStream;
    import java.io.FileNotFoundException;
    import java.io.FileOutputStream;
    import java.io.IOException;
    
    public class ByteStreamTester {
    
        public static void main(String [] args)
        {
            FileInputStream in = null;
            FileOutputStream out = null;
            String path = "E:\\java\\";
            try
            {
                in = new FileInputStream(path+"IOFile.txt");
                out = new FileOutputStream(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();
                }
                
            }
        }
    }
  • 相关阅读:
    10-3 集合之Set
    【Angular】排序
    【Mongous】
    【验证码】
    爬虫
    【DOM】
    年月日
    【Mocha】
    【Test】
    洛谷——P1823 音乐会的等待
  • 原文地址:https://www.cnblogs.com/ghmgm/p/4354778.html
Copyright © 2011-2022 走看看