Basically, I have a text file with rows that correspond to an objects description (variables of the object). By this, I mean for instance, a row could look like: String int int double int long. Now, I have an empty array of those type of objects. My goal is to transfer the objects from the text file, to the array. I have searched for a solution though I have not found anything. Here is what I tried to do. I got a java.util.InputMismatchException though I do not know how to solve the issue. Thank you very much for your help.
Scanner transfer = new Scanner (new FileInputStream(a));
// we use a simple for loop to set every variable of the object to the file's order.
for (int i = 0 ; i< Array.length; i++){
Array[i].setLong(transfer.nextLong());
Array[i].setString(transfer.next());
Array[i].setInt(transfer.nextInt());
Array[i].setString(transfer.next());
Array[i].setDouble(transfer.nextDouble());
Array[i].setInt(transfer.nextInt());
}
transfer.close();
Edit2 new stack trace happening at the first transfer
Exception in thread "main" java.lang.NullPointerException
at Driver.main(Driver.java:31)