📄 filecopier.java
字号:
package com.justin.util;
import java.io.*;
import java.nio.*;
import java.nio.channels.*;
public class FileCopier {
public static void copy(String inFilePath, String outFilePath)
throws IOException {
FileInputStream fin = null;
RandomAccessFile fout = null;
try {
fin = new FileInputStream(inFilePath);
fout = new RandomAccessFile(outFilePath, "rw");
FileChannel in = fin.getChannel();
FileChannel out = fout.getChannel();
MappedByteBuffer input = in.map(FileChannel.MapMode.READ_ONLY, 0,
in.size());
MappedByteBuffer output = out.map(FileChannel.MapMode.READ_WRITE,
0, in.size());
output.put(input);
} finally {
try {
if (fin != null)
fin.close();
} catch (IOException ex) {
}
try {
if (fout != null)
fout.close();
} catch (IOException ex) {
}
}
}
public static void main(String[] args) {
try {
copy("D:\\ExcelFile\\test1.xls", "E:\\xu.xls");
System.out.println("successful");
}
catch (IOException ex){
System.err.println(ex);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -