filedemo12.java
来自「JAVA程序设计课程中各章节的程序实例。」· Java 代码 · 共 37 行
JAVA
37 行
/**
*This is another sample program that uses FileInputStream and FileOutputStream
* along with the class File.
*The program creates a backup file for this java file,the name of the backup file's called
* backup.txt.When you run the program,backup.txt is created inside the directory
* where this program is saved
*2004.12.30. xhcprince
*/
import java.io.*;
class fileDemo12
{
public static void main(String args[])throws IOException
{
File f1 = new File("fileDemo12.java");
if(f1.exists()==true && f1.isFile()==true)
{
FileInputStream fin = new FileInputStream(f1);
FileOutputStream fout = new FileOutputStream("backup.txt");
int len = (int)f1.length();
int i;
for(i=1; i<=len; ++i)
{
char ch = (char)fin.read();
fout.write(ch);
}
fin.close();
fout.flush();
fout.close();
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?