write(int): This method is available in the java.io.FileOutputStream class of Java.
Syntax:
void java.io.FileOutputStream.write(int b) throws IOException
This method takes one argument. This method writes the specified byte to this file output stream.
Note:
1. It implements the write method of OutputStream.
Parameters: One parameter is required for this method.
b: the byte to be written.
Throws:
IOException - if an I/O error occurs.
Approach
Java
import java.io.File;import java.io.FileOutputStream;import java.io.IOException;public class FileOutputStreamwrite2 {public static void main(String[] args) throws IOException {String pathname = "D:\\hello.txt";File file = new File(pathname);FileOutputStream fileOutputStream =new FileOutputStream(file);int b = 'a';fileOutputStream.write(b);System.out.println("Successfully writes");fileOutputStream.close();}}
Output:
Successfully writes
No comments:
Post a Comment