Create try and catch block that opens a file named statistics.txt for output.
Writes the integers 24,
55, and 76 to the file, and then closes the file.
```
PrintWriter outputStream = null;
try
{
outputStream = new PrintWriter(new
FileOutputStream("statistics.txt"));
outputStream.println(24);
outputStream.println(55);
outputStream.println(76);
outputStream.close();
}
catch(FileNotFoundException e)
{
System.out.println("Error opening the file autos.txt");
System.exit(0);
}
```
You might also like to view...
What is the difference between a calling function and a called function?
What will be an ideal response?
Select the technology that was developed by a joint effort between Netscape and Sun Microsystems.
a. Java b. JavaScript c. Flash d. Ajax
Answer the following statements true (T) or false (F)
1. The contents of memory on a running system will change for no apparent reason while the system is sitting there doing nothing. 2. A DoD approved disk wiping utility works by instructing the hard disk controller to apply a strong magnetic field to the disk surface, thereby electronically erasing the information from the disk. 3. Once a file has been deleted from the Recycle Bin in Windows 7, it is no longer salvagable under any circumstances. 4. Changing a file's extension in Windows makes the file completely unreadable by the operating system. 5. Even after a file is emptied from the Recycle Bin, there remains an entry for that file in the MFT. 6. A general rule of thumb regarding file headers is that a humanly readable file has a humanly readable header.
What does the following statement do?
Scanner scanner = new Scanner(Paths.get("test.txt")); a. Opens a binary file for input. b. Opens a binary file for output. c. Opens a text file for input. d. Opens a text file for output.