I have this small problem of mine, where I would be getting arrayindexoutofboundsexception when trying to read from file. I don't know of a better or more detailed way of explaining it, so I will paste the code and the error below. This is all in the mainmethod of my program.
File fila;
String[] innlesningsarray=new String[500];
try{
Scanner innFil=new Scanner(new File("/uio/hume/student-u77/makrist/Downloads/akronymer.txt"));
while(innFil.hasNext()){
for(int i=0; i<500; i++){
// String innLest=br.nextLine();
innlesningsarray=innFil.nextLine().split("\t");
System.out.println(innlesningsarray[i]);
System.out.println(innFil.nextLine());
}
System.out.println("test");
}
System.out.println("Test2");
} catch(Exception e){
System.out.print(e);
}
}
}
After this part I have an object of Acronyms and stuff, but no errors there...
The error:
AA Auto Answer
AAB All-to-All Broadcast
java.lang.ArrayIndexOutOfBoundsException: 1
print(e)you should writee.printStackTrace(). This will print a lot of useful information about the exception.