⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 filedemo12.java

📁 JAVA程序设计课程中各章节的程序实例。
💻 JAVA
字号:
/**
*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 + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -