码迷,mamicode.com
首页 > 其他好文 > 详细

i/o流

时间:2017-05-08 12:15:53      阅读:121      评论:0      收藏:0      [点我收藏+]

标签:默认值   stat   input   row   new   ati   oid   txt   throws   

public class TestCopyArray {
  public static void main(String[] args) throws Exception {
    InputStream is = new FileInputStream("第10章/a.txt");
    OutputStream os = new FileOutputStream("第10章/b.txt");
    byte[] bs = new byte[1024];
    while(true){
      int length = is.read(bs);
      //从下标0开始,把length长度写到文件中
      os.write(bs,0,length);
      if(length<1024){
        break;
    }
  }
  is.close();
  os.close();
  }
}

注意:a.boolean:表示是否向文件末尾追加,如果是true表示追加,false表示不追加(也就是覆盖),默认值是false;

   b.创建FileOutputStream实例时,如果相应的文件并不存在,则会自动创建一个空的文件。

i/o流

标签:默认值   stat   input   row   new   ati   oid   txt   throws   

原文地址:http://www.cnblogs.com/dahaoheshan/p/6824138.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!