首页 > 其他 > 详细

使用字节缓冲流在文件中写内容

时间:2019-03-26 18:37:59      阅读:148      评论:0      收藏:0      [点我收藏+]

package text;

import java.io.BufferedOutputStream;

import java.io.FileOutputStream;
import java.io.IOException;

public class Buff2 {


      public static void main(String[] args) {


            BufferedOutputStream bos=null;


            try {


//                  使用字节缓冲在文件中写内容


                 bos=new BufferedOutputStream(new FileOutputStream("D:\\IO\\java.txt",true));


//                   写入内容


                bos.write(65);


//                写入字符串


                byte []b="hello word\r\nhttp".getBytes();


                bos.write(b);


//              截取的内容重一遍


              bos.write(b,1,3);
            
            
          } catch (IOException e) {
            
              e.printStackTrace();


            }finally{


              if(bos!=null){


                  try {


                        bos.close();


                    } catch (IOException e) {


                        e.printStackTrace();


                }
            }
        }
    }
}

使用字节缓冲流在文件中写内容

原文:https://www.cnblogs.com/hph1728390/p/10602083.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!