This program will write the content into the file using FileOutputStream class. In this program we are using FileOutputStream.write() method which writes the value in bytes, so we have to convert String data into bytes.
- String.getBytes() - returns the bytes array.
- FileOutputStream.flush() - Is used to clear the output steam buffer.
- FileOutputStream.close() - Is used to close output stream (Close the file).
-
Write Content into File using FileOutputStream in Java
Output: