Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.company;
- import java.io.IOException;
- import java.nio.file.Paths;
- import java.util.NoSuchElementException;
- import java.util.Scanner;
- public class Main
- {
- private Scanner input;
- public static void main(String[] args)
- {
- developerInfo();
- Main myObject = new Main();
- myObject.openFile();
- }
- public void openFile()
- {
- try
- {
- input = new Scanner(Paths.get("Program6.txt"));
- }
- catch (IOException ioException)
- {
- System.err.println("Error opening file. Terminating.");
- System.exit(1);
- }
- }
- // Read records from the file
- public void readRecords()
- {
- try
- {
- while (input.hasNext()) // while there is more to read
- {
- // display record contents
- System.out.printf("%10.2f%n", input.nextDouble());
- }
- }
- catch (NoSuchElementException elementException)
- {
- System.err.println("File improperly formed. Terminating.");
- }
- catch (IllegalStateException stateException)
- {
- System.err.println("Error reading from file. Terminating.");
- }
- }
- public static void developerInfo()
- {
- System.out.println ("Name: Jon Elliott");
- System.out.println ("Course: ITSE 2321 Object-Oriented Programming");
- System.out.println ("Program: Four \n");
- } // End of developerInfo
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement