List<Integer> tempBooksReference = new ArrayList<>();
List<String> tempBooksTitle = new ArrayList<>();
BufferedReader br = null;
try
{
br = new BufferedReader(new FileReader("C:\\Users\\SGGS\\Documents\\NetBeansProjects\\JavaApplication3\\src\\javaapplication3\\input"));
\*Here you can give full path of your input file or you have to resolve it using URL class method check documentation of URL class and pay attention to cases it String and Integer in Generics*/
String nextLine;
String bookTitle;
int bookNum;
while ((nextLine = br.readLine()) != null) {
bookNum=Integer.parseInt(nextLine);
tempBooksReference.add(bookNum);
bookTitle=br.readLine();
tempBooksTitle.add(bookTitle);
}
System.out.println(tempBooksTitle.size());
br.close();
Integer[] booksReference = new Integer[tempBooksReference.size()];
String[] booksTitle = new String[tempBooksTitle.size()];
tempBooksReference.toArray(booksReference);
tempBooksTitle.toArray(booksTitle);
System.out.println(Arrays.toString(booksTitle));
}
catch (IOException e)
{
System.out.println(e.getMessage());
}