zoukankan      html  css  js  c++  java
  • 使用字节缓冲流在文件中写内容

    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 http".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();


                    }
                }
            }
        }
    }

  • 相关阅读:
    迈瑞医疗招聘-软件测试工程师
    软件自动化测试开发-3期开班啦
    luogu P2744 [USACO5.3]量取牛奶Milk Measuring
    luogu P2515 [HAOI2010]软件安装
    luogu P2423 双塔
    luogu P1651 塔
    luogu P1489 猫狗大战
    luogu P3092 [USACO13NOV]没有找零No Change
    luogu P3800 Power收集
    luogu P2949 [USACO09OPEN]工作调度Work Scheduling
  • 原文地址:https://www.cnblogs.com/hph1728390/p/10602083.html
Copyright © 2011-2022 走看看