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



    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 (Exception e) {

               e.printStackTrace();


            }finally{


                    if(bos!=null){


                          try {


                            bos.close();


                    } catch (IOException e) {


           
                        e.printStackTrace();


                    }
                }
            }

        }

    }

  • 相关阅读:
    【Docker】解析器指令之 escape
    【Docker】解析器指令之 syntax
    【Docker】Dockerfile 解析器指令
    【Docker】Dockerfile 格式
    【Docker】Dockerfile 介绍
    【Docker】Spring Boot 和 Docker
    【Docker】理解 Docker 中的 OverlayFS
    【Docker】使用 OverlayFS 存储驱动
    【Docker】选择存储驱动
    kuangbin专题 专题一 简单搜索 Fire! UVA
  • 原文地址:https://www.cnblogs.com/hph1728390/p/10601319.html
Copyright © 2011-2022 走看看