zoukankan      html  css  js  c++  java
  • 考试第10题

    package test10;
    
    import java.io.FileInputStream;
    import java.io.FileNotFoundException;
    import java.io.FileOutputStream;
    import java.io.IOException;
    
    public class CopyImages {
    
        //复制图片
        //1、地址  2、读取 FileInput   再输出FileOut
        
        public static void main(String[] args) {
            
            FileInputStream fis = null;
            FileOutputStream fos = null;
            
            try {
                fis = new FileInputStream("C:/Users/admin/Desktop/1.jpg");
                fos = new FileOutputStream("C:/Users/admin/Desktop/2.jpg");
                int num = -1;
                try {
                    while((num=fis.read())!=-1) {
                        
                    
                        fos.write(num);
                        fos.flush();
                        
                    }
                    System.out.println("复制成功!");
                } catch (IOException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            } catch (FileNotFoundException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }finally {
                try {
                    fos.close();
                    fis.close();
                    
                } catch (IOException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            }
        }
    }

  • 相关阅读:
    面试问题记录
    面试问题记录
    面试问题记录
    JavaScript => ?
    Jsr303数据校验
    在浏览器上开发GO和Vue!(基于code-server)
    IdentityServer4 4.0.0
    9/13-9/18
    9/6-9/10
    8/30-9/3
  • 原文地址:https://www.cnblogs.com/bichen-01/p/11336464.html
Copyright © 2011-2022 走看看