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

📄 usebuffer.java

📁 这是孙卫琴在"Java与面向对象编程"一书的源代码。
💻 JAVA
字号:
import java.io.*;
public class UseBuffer{
  public static void main(String agrs[])throws IOException{
    final int SIZE=1024;
    FileInputStream in=new FileInputStream("D:\\test.txt");
    FileOutputStream out=new FileOutputStream("D:\\out.txt");

    byte[] buff=new byte[SIZE];  //创建字节数组缓冲区

    int len=in.read(buff);  //把test.txt文件中的数据读入到buff中
    while(len!=-1){
      out.write(buff,0,len);  //把buff中的数据写到out.txt文件中
      len=in.read(buff);
    }
    in.close();
    out.close();
  }
}




/****************************************************
 * 作者:孙卫琴                                     *
 * 来源:<<Java面向对象编程>>                       *
 * 技术支持网址:www.javathinker.org                *
 ***************************************************/

⌨️ 快捷键说明

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