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

📄 fileioexam.java

📁 Java程序设计实用教程源代码 本书源代码按章分别放置在不同的文件夹中,所有程序均在JDK1.6环境下编译运行正常,除了第13章需要建立ODBC数据源之外,其他程序只要有Java运行环境即可直接运行
💻 JAVA
字号:
import java.io.*;
public class FileIOExam {
  public static void main(String args[]) throws IOException {
    FileInputStream in = new FileInputStream("character.txt");
    int i = 0;
    int c;
    while ( (c = in.read()) != -1) {
      System.out.print( (char) c);
      i++;
    }
    System.out.println("\n读取字节数:" + i);
    in.close();
    in = new FileInputStream("C:\\WINDOWS\\system32\\spider.exe");
    FileOutputStream out = new FileOutputStream("mySpider.exe");
    System.out.println("文件大小:" + in.available());
    byte b[] = new byte[in.available()];
    in.read(b);
    out.write(b);
    System.out.println("file copyed and renamed");
    in.close(); ;
    out.close();
  }
}

⌨️ 快捷键说明

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