?? acopy_of_java_file.java
字號(hào):
/*
程序標(biāo)題:利用字節(jié)流將本程序拷貝至另一個(gè)文件acopy_of_java_file中,如果指定的文件不存在,則創(chuàng)建一個(gè)新文件,否則原文件的內(nèi)容會(huì)被新寫入的內(nèi)容覆蓋。當(dāng)程序運(yùn)行后,將生成一個(gè)與原程序相同的副本。
程序作者:柯培宗2202010
日期:2004_12_30
*/
import java.io.*;
public class FileCopy
{
public static void main(String args[]) throws IOException
{
FileInputStream f1;
FileOutputStream f2;
f1=new FileInputStream("FileCopy.java");
f2=new FileOutputStream("acopy_of_java_file.java");
int temp;//臨時(shí)存儲(chǔ)值
while((temp=f1.read())!=-1)//如果f1文件不為空的話
f2.write(temp);//將f1的內(nèi)容寫入f2
f1.close();//關(guān)閉f1
f2.close();//關(guān)閉f2
System.out.println("備份文件成功!");
}
public FileCopy() { }//空構(gòu)造函數(shù)
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -