📄 copyfile.java
字号:
// 例5.3.3 CopyFile.java
import java.io.*;
class CopyFile
{
public static void main(String args[])
{
int i;
FileInputStream fin = null;
FileOutputStream fout = null;
try
{
// 打开输入流
try
{
fin = new FileInputStream("ReadFileExample.doc");
} catch(FileNotFoundException e) {
System.out.println("Input File Not Found");
}
// 打开输出流
try
{
fout = new FileOutputStream("CopyFileExample.doc");
}catch(FileNotFoundException e) {
System.out.println("Error Opening Output File");
}
// 进行文件拷贝
while ((i = fin.read())!=-1)
{
fout.write(i);
}
fin.close();
fout.close();
}catch(IOException e) {
System.out.println("File Error");
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -