Cracked the problem
Glad you sorted it, (while I was typing an answer ) but I’ll throw in another suggestion to prevent other similar problems that might occur:
The Scanner class is designed for just this sort of file parsing, there’s no point using it just to read the file into a string array and then parsing that ‘manually’ using Integer.parseInt() and so on. A better approach would be to leverage the various methods Scanner provide and get rid of the nasty array altogether, i.e. something like the following pseudo-code:
// Open the file
final Scanner sc = new Scanner( ... );
// Get number of items
final int count = sc.nextInt();
final Building[] buildings = new Building[ count ];
// Load items
for( int n = 0; n < count; ++n ) {
final String name = sc.next();
final int a = sc.nextInt();
final int b = sc.nextInt();
buildings[ n ] = new Building( name, a, b );
...
}
- stride