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

📄 testfileinputstream.java

📁 本书是一本为Java学习者在基础内容学习结束后进行课程设计时提供参考的指导书
💻 JAVA
字号:
package apibook.c3.s5;import java.io.*;//测试FileInputStream类public class TestFileInputStream {  public TestFileInputStream() {  }  public static void main(String[] args) {    try {      String infile = "TestFileInputStream.in";      String outfile = "TestFileInputStream.txt";      File f = new File(infile);      FileInputStream in = new FileInputStream(f);      FileOutputStream out = new FileOutputStream(outfile);      long size = f.length();//得到文件长读      in.skip(size/2);//设置跳过文件长度的一半      byte[] buf = new byte[512];      int count;      while ((count = in.read(buf)) > 0) {//从输入文件读数据        out.write(buf, 0, count);//将数据写入输出文件      }      in.close();//关闭输入文件      out.close();//关闭输出文件    } catch (FileNotFoundException e) {      System.err.println("File is not found");    } catch (IOException e) {      e.printStackTrace();    }  }}

⌨️ 快捷键说明

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