/home/caleb/ASDV-Java/Semester 2/Assignments/lab6-Exceptions_CalebFontenot/src/main/java/com/mycompany/lab6/exceptions_calebfontenot/WriteWithAutoClose.java
/*
 * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
 * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
 */
package com.mycompany.lab6.exceptions_calebfontenot;

import java.io.IOException;

/**
 *
 * @author caleb
 */
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);
        }
        
        //throw new IOException(); //Just for testing :)
        
        try (java.io.PrintWriter output = new java.io.PrintWriter(file);) {
            // Write formatted output to the file
            output.print("John T Smith ");
            output.println(90);
            output.print("Eric K Jones ");
            output.println(85);
        }
    }
}