Java FileOutputStream write() Example
FileOutputStream class write() method example. This example shows you how to use write() method.
Syntax is : public void write(int b) throws IOException
Method writes the specified byte to this file output stream. Implements the write method of OutputStream.
Here is the code.
/**
* @(#) Write2FileOutputStream.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 Write2FileOutputStream {
public static void main(String[] args) throws IOException {
// Create object of FileOutputStream class
FileOutputStream objFileStream = new FileOutputStream("MAHENDRA");
// write() method call.
objFileStream.write(65);
System.out.print("Specified int value has written successfully to "
+ "file output stream.");
}
} |
output of the program.
| Specified byte subarray has written successfully to file output stream. |
|