?? filecopy.java
字號:
package merge;
import java.nio.channels.*;
import java.io.*;
public class FileCopy{
public static void main(String args[]){
try {
FileCopy j = new FileCopy();
j.copyFile(new File("1.txt"),new File("1copy.txt"));
File f=new File("1copy.txt");
f.renameTo(new File("1c.txt"));
}catch (Exception e) {
e.printStackTrace();
}
}
public void copyFile(File in, File out) throws Exception {
FileChannel sourceChannel = new FileInputStream(in).getChannel();
FileChannel destinationChannel = new FileOutputStream(out).getChannel();
sourceChannel.transferTo(0, sourceChannel.size(), destinationChannel);
// or
// destinationChannel.transferFrom(sourceChannel, 0, sourceChannel.size());
sourceChannel.close();
destinationChannel.close();
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -