⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 filecopy4.java

📁 JAVA SE6 全方位学习 朱仲杰 编著 机械工业出版社出版
💻 JAVA
字号:
import java.io.*;
import java.nio.*;
import java.nio.channels.*;

public class FileCopy4
{
	public static void main(String args[]) throws Exception
	{
		FileInputStream fin = new FileInputStream(args[0]);
		FileChannel fcin = fin.getChannel();
		FileOutputStream fout = new FileOutputStream(args[1]);
		FileChannel fcout = fout.getChannel();
		
		long st = System.currentTimeMillis();
		System.out.println("Begin copy...");

		MappedByteBuffer mb = fcin.map(FileChannel.MapMode.READ_ONLY, 0, fcin.size());
		fcout.write(mb);

		fcout.close();
		fcin.close();
		fin.close();
		fout.close();
		
		System.out.println("Copy completed!");
		System.out.println("Spend "+(System.currentTimeMillis()-st)+" ms.");
		
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -