A股上市公司传智教育(股票代码 003032)旗下技术交流社区北京昌平校区

  1. package com.heima.test;

  2. import java.io.BufferedInputStream;
  3. import java.io.BufferedOutputStream;
  4. import java.io.FileInputStream;
  5. import java.io.FileOutputStream;
  6. import java.io.IOException;

  7. public class Test1_fileInPutStream {

  8.         /**
  9.          * @param args
  10.          * @throws IOException
  11.          */
  12.         public static void main(String[] args) throws IOException {
  13.                 //FileInputStream fis = new FileInputStream("xxx.txt");                                                                                 //使用自定义数组拷贝文件                     
  14.                 BufferedInputStream bis = new BufferedInputStream(new FileInputStream("xxx.txt"));  //使用高效流拷贝文件
  15.                 //FileOutputStream fos = new FileOutputStream("copy.txt");
  16.                 BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream("copy.txt"));
  17.                 int a ;
  18.                 while ((a = bis.read()) != -1) {
  19.                         bos.write(a);
  20.                 }
  21.                 bis.close ();
  22.                 bos.close ();
  23.         }
  24. }
复制代码
您需要登录后才可以回帖 登录 | 加入黑马