Java-音乐文件拷贝

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/dyw_666666/article/details/84072312
package io;

import java.io.*;

public class CopyFile {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		try {
			FileInputStream fis = new FileInputStream("D:/KuGou/毛不易 - 不染.mp3");
			FileOutputStream fos = new FileOutputStream("D:\\666.mp3");
			
			long start = System.currentTimeMillis(); //获取拷贝文件前的系统时间
			
			int len;
			while((len = fis.read()) !=-1) {
				fos.write(len);
			}
			
			long end = System.currentTimeMillis(); //获取拷贝文件后的系统时间
			System.out.println("拷贝文件所消耗的时间是:"+(end-start)+"毫秒");
			
			fis.close();  //关闭流
			fos.close();  //关闭流
			
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

}

猜你喜欢

转载自blog.csdn.net/dyw_666666/article/details/84072312
今日推荐