1
public static void getBooks(){

    int bookNum = 0;
    bookFile = new File(args[0]);
    Scanner input = new Scanner(bookFile);

    while (input.hasNextLine()) {
        bookNum += 1;
        input = input.nextLine();
    }
    ...
}

I need it to add the number of books as long as there are books to add meaning while there is a next line.

Sotirios Delimanolis
  • 252,278
  • 54
  • 635
  • 683
missyj
  • 47
  • 1
  • 1
  • 7

2 Answers2

1

The problem is here:

    input = input.nextLine();

The two inputs are probably meant to be two separate variables. Change this to something like:

    String line = input.nextLine();
    // use `line' here
NPE
  • 438,426
  • 93
  • 887
  • 970
0

This input = input.nextLine(); makes no sense. What do you want to do? Just run input.nextLine()

Piotr Gwiazda
  • 11,796
  • 12
  • 53
  • 87