Java FileOutputStream ClassJava 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 declarationLet's see the declaration for Java.io.FileOutputStream class: FileOutputStream class methods
Java FileOutputStream Example 1: write byteOutput: Success... The content of a text file testout.txt is set with the data A. testout.txt A Java FileOutputStream example 2: write stringOutput: Success... The content of a text file testout.txt is set with the data Welcome to javaTpoint. testout.txt Welcome to javaTpoint. Next TopicJava FileInputStream Class |