?? copyfile.java
字號:
//源文件名:copyFile.java
//在下載源程序中的文件夾:1006復制文件
import java.io.*;
public class copyFile
{
public static void main(String args[]) throws IOException
{
File f1,f2;
f1 = new File(".","sourceFile.txt");
f2 = new File(".\\subDir","targetFile.txt");
copy(f1,f2);
System.exit(0);
}
public static void copy(File f1,File f2) throws IOException
{
FileInputStream rf = new FileInputStream(f1);
FileOutputStream wf = new FileOutputStream(f2);
int count,n=512;
byte buffer[] = new byte[n];
count = rf.read(buffer,0,n);
while (count != -1)
{
wf.write(buffer,0,count);
count = rf.read(buffer,0,n);
}
System.out.println("已經把文件“"+f1.getPath()+"”復制為“"+f2.getPath()+"”");
rf.close();
wf.close();
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -