Java BufferedOutputStream write() Example

BufferedOutputStream class write() method example. This example shows you how to use write() method.


Syntax is : public void write(byte[] b, int off, int len) throws IOException
Method writes len bytes from the specified byte array starting at offset off to this buffered output stream.

Here is the code.
/**
 * @(#) Write1BufferedOutputStream.java
 * A class representing use of method write() of BufferedOutputStream 
 class in java.io Package.
 * @Version  05-May-2008
 @author   Rose India Team
 */
import java.io.*;
public class Write1BufferedOutputStream {
     public static void main(String[] argsthrows IOException{
      
      String str = "MAHENDRA ";
    byte[] byteArray = new byte[]{'S','I','N','G','H'};

      // Create object of FileOutputStream class.
        FileOutputStream objFileStream = new FileOutputStream("MAHENDRA");

    // Create object of BufferedOutputStream class.
    BufferedOutputStream obj = new BufferedOutputStream(objFileStream);
       
    // write() method call.
        obj.write(byteArray, 05);
     System.out.print("write method successfully written specified subarray.");
    }   
}

Output of the program.
write method successfully written specified subarray.

Post Comment
Name:
E-mail:
Contact no :
Comments:
  Refresh Image
Verify Image:
 
 
Your Comment's
 
 
 

HOME | COPYRIGHT | CONTACT US