BufferedOutputStream class

                                             
    java.lang.Object                                        
     |                                       
     |--java.io.OutputStream                                    
         |                                   
         |--java.io.FilterOutputStream                                
             |                               
             |--java.io.BufferedOutputStream                            
                                             

The class implements a buffered output stream.

ConstructorSummary
BufferedOutputStream(OutputStream out)Creates a new buffered output stream to write data to the specified underlying output stream.
BufferedOutputStream(OutputStream out, int size)Creates a new buffered output stream to write data to the specified underlying output stream with the specified buffer size.

ReturnMethodSummary
voidflush()Flushes this buffered output stream.
voidwrite(byte[] b, int off, int len)Writes len bytes from the specified byte array starting at offset off to this buffered output stream.
voidwrite(int b)Writes the specified byte to this buffered output stream.
Revised from Open JDK source code

import java.io.BufferedOutputStream;
import java.io.FileOutputStream;

public class Main {

  public static void main(String[] args) throws Exception {
    BufferedOutputStream bufferedOutput = new BufferedOutputStream(new FileOutputStream(
        "yourFile.txt"));
    bufferedOutput.write("java2s.com".getBytes());
    bufferedOutput.write("\n".getBytes());
    bufferedOutput.write('a');

    bufferedOutput.write(65);
    bufferedOutput.close();
  }
}
java2s.com  |  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.