/home/caleb/ASDV-Java/Semester 2/Assignments/lab6-Exceptions_CalebFontenot/src/main/java/com/mycompany/lab6/exceptions_calebfontenot/WriteWithAutoClose.java |
nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt
nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java
package com.mycompany.lab6.exceptions_calebfontenot;
import java.io.IOException;
@author
public class WriteWithAutoClose {
public static void main(String[] args) throws IOException
{
java.io.File file = new java.io.File("scores.txt");
if (file.exists()) {
System.out.println("File already exists!");
System.exit(0);
}
try (java.io.PrintWriter output = new java.io.PrintWriter(file);) {
output.print("John T Smith ");
output.println(90);
output.print("Eric K Jones ");
output.println(85);
}
}
}