0

enter image description here

When the GUI first starts, the readFile method is called to fill the Book arraylist. This is done in the GUI constructor. Then, the user can add new books through the GUI form.

ublic static void readFile() {

    Book b = new Book();
    //Scanner b = new Scanner(new File("books.txt")

    FileInputStream input;      // Stream to read file
    try
    {
        input = new FileInputStream ("books.txt"); // Open an input stream
        System.out.println(new DataInputStream(input).readLine()); // Read a line of text
        input.close();      // Close our input stream
    }

    catch (IOException e) // Catches any error conditions
    {
        System.err.println ("Unable to read from file");
        System.exit(-1);
    }

    while (input.hasNext()) 
    {
        bookList.add(b.next());
    }
    b.close();

0 Answers0