FileOutputStream

Classic programmed-learning exercises, refreshed for modern Java and presented in the current MrStyner.com portfolio style.

Modern Java noteThis archive has been refreshed for Java 25 LTS. Core language concepts remain useful, while outdated setup instructions and browser-era Java are labeled or replaced. Java 26 is the current feature release; Java 25 is used here as the stable teaching baseline.
go to previous page   go to home page   go to next page        

Answer:

String

FileOutputStream

Here are the constructors of the FileOutputStream Class:

Constructors

FileOutputStream(String name) throws FileNotFoundException
    Creates an output stream that writes to the file. 

FileOutputStream(String name, boolean append) throws FileNotFoundException
    Creates an output stream. If append is true append bytes 
    to the end of the file. 

The second constructor opens a disk file for appending. Since we will always use DataOutputStream with a FileOutputStream we don't need to look at the methods (look in your on-line documentation if you want).

QUESTION 10:

Will the following statement work?

DataOutputStream dataOut = new DataOutputStream( "myFile.dat" );