Java FileOutputStream Class
Java FileOutputStream is an output stream used for writing data to a file.
If you have to write primitive values into a file, use FileOutputStream class. You can write byte-oriented as well as character-oriented data through FileOutputStream class. But, for character-oriented data, it is preferred to use FileWriter than FileOutputStream.
FileOutputStream class declaration
Let's see the declaration for Java.io.FileOutputStream class:
FileOutputStream class methods
Java FileOutputStream Example 1: write byte
The content of a text file testout.txt is set with the data A.
Java FileOutputStream example 2: write string
The content of a text file testout.txt is set with the data Welcome to javaTpoint.
Welcome to javaTpoint.