zoukankan      html  css  js  c++  java
  • 使用输入流和输出流的知识,复制文件从源文件路径到目标路径

    package com.itcast.demo02.InputStream;

    import java.io.FileInputStream;
    import java.io.FileOutputStream;
    import java.io.IOException;

    /**
    * @author newcityman
    * @date 2019/7/28 - 9:38
    * 题目要求:
    * 使用输入流和输出流的知识,复制文件从源文件路径到目标路径
    */
    public class Demo03InputStream {
    public static void main(String[] args) throws IOException {
    long l = System.currentTimeMillis();
    FileInputStream fis = new FileInputStream("D:\节日任务.docx");
    FileOutputStream fos = new FileOutputStream("F:\1.docx");
    byte[] bytes = new byte[2048];
    int len = 0;
    while((len=fis.read(bytes))!=-1){
    fos.write(bytes,0,len);
    }
    fis.close();
    fos.close();
    long l1 = System.currentTimeMillis();
    System.out.println("总耗时:"+(l1-l)+"毫秒");

    }
    }
  • 相关阅读:
    单例 与 static
    ActiveMQ 核心概念
    Jconsole
    死锁
    document write & close
    java.nio.Buffer
    Java 线程控制(输出奇偶数)
    exist & in
    命运
    Super Jumping! Jumping! Jumping!
  • 原文地址:https://www.cnblogs.com/newcityboy/p/11257882.html
Copyright © 2011-2022 走看看