Java FileOutputStream write() Example

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


Syntax is : public void write(byte[] b) throws IOException
This method writes b.length bytes from the specified byte array to this file output stream.

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

     // Create object of FileOutputStream class
         FileOutputStream objFileStream = new FileOutputStream("MAHENDRA");
         
    // write() method call.
        objFileStream.write(byteArray);
        System.out.print("Specified byte array has written successfully to "
    "file output stream.");
    }   
}

output of the program.
Specified byte array has written successfully to file output stream.

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

HOME | COPYRIGHT | CONTACT US