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();


                }
            }
        }
    }
}

相关文章:

  • 2021-10-11
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-26
  • 2021-08-05
  • 2021-07-01
猜你喜欢
  • 2021-10-23
  • 2022-12-23
  • 2022-01-13
  • 2022-12-23
  • 2022-12-23
  • 2022-01-06
  • 2022-12-23
相关资源
相似解决方案