zoukankan      html  css  js  c++  java
  • 图片拷贝

    import java.io.File;
    import java.io.FileInputStream;
    import java.io.FileOutputStream;
    import java.io.IOException;
      
      
    public class demo6 {
      
        /**
         * 把一张图片拷贝到指定的位置
         
         */
        public static void main(String[] args) throws IOException {
            //拿到图片的路径
            File file = new File("C:\Users\PC-LUO\Desktop\新建文件夹\98.jpg");
            //创建拷贝后的路径
            File file2 = new File("C:\Users\PC-LUO\Desktop\4.jpg");
              
            image(file, file2);
        }
          
        //拷贝操作
        public static void image(File file , File file2) throws IOException{
              
            //输入流
            FileInputStream inputStream = new FileInputStream(file);
            //输出流
            FileOutputStream outputStream = new FileOutputStream(file2);
              
            //创建缓冲区,大小为1K
            byte[] b = new byte[1024];
              
            //循环遍历文件内容,没有就返回-1
            while (inputStream.read(b) != -1) {
                //把得到的数据写入到指定位置
                outputStream.write(b);  
            }
            //关闭资源
            outputStream.close();
            inputStream.close();
        }
      
    }
  • 相关阅读:
    mojo 接口示例
    MojoliciousLite: 实时的web框架 概述
    接口返回json
    centos 6.7 perl 版本 This is perl 5, version 22 安装DBI DBD
    centos 6.7 perl 5.22 安装DBD 需要使用老的perl版本
    商业智能改变汽车行业
    商业智能改变汽车行业
    读MBA经历回顾(上)目的决定手段——北漂18年(48)
    perl 升级到5.20版本
    Group Commit of Binary Log
  • 原文地址:https://www.cnblogs.com/zh-0802/p/6134703.html
Copyright © 2011-2022 走看看