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

📄 copyfile.java

📁 压缩包内是近180多个针对Java初学者编写的简单实例
💻 JAVA
字号:
// FileInputStrem和FileOutputStream的综合应用。
import java.io.*;
class CopyFile {
  public static void main(String args[]) 
    throws IOException
  {
    int i;
    FileInputStream opfin;
    FileOutputStream opfout;
      try {
        opfin = new FileInputStream("test11_1.txt");           // 打开输入文件
      } catch(FileNotFoundException exc)
	 {
        System.out.println("Input File Not Found");
        return;
      }
      try {
        opfout = new FileOutputStream("test11_2.txt");        // 打开输出文件
      } catch(FileNotFoundException exc) {
        System.out.println("Error Opening Output File");
        return;
      }
    try {                                             // 复制文件
      do {
        i = opfin.read();   
        if(i != -1) opfout.write(i);
      } while(i != -1);
    } catch(IOException exc)
		{
      System.out.println("File Error");
    }
    opfin.close();
    opfout.close();
  }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -