Java I/O – How to write to a file using FileOutputStream






In the previous examples How to create a file in Java. Now in this example we will see how to write to a file in Java using FileOutputStream class.

  • A FileOutputStream writes to a file on disk
  • FileOutputStream is meant for writing streams of raw bytes such as image data. For writing streams of characters, consider using FileWriter.

So Lets see the example below.