eclipse - Exception in thread "main" java.util.NoSuchElementException - not sure what's going wrong -


i'm trying write scanner take dataset , parses array. experiencing exception:

exception in thread "main" java.util.nosuchelementexception     @ java.util.scanner.throwfor(scanner.java:907)     @ java.util.scanner.next(scanner.java:1416)     @ neural.neuralmain.readfile(neuralmain.java:34)     @ neural.neuralmain.<init>(neuralmain.java:97)     @ neural.neuralmain.main(neuralmain.java:201) 

i have seen number of topics on topic here, , seem to checking there being next item available scanner. under impression code did this, appreciated.

here relevant section of code:

public int[][] readfile( int[][] inputarray, string filename, int datatype) {      // "try" block used, constructor throw exception should filename not recognised.     try {         // code reads scanner, in, attached filename.         scanner input = new scanner( new file( filename ) );          //initialising array store input data.         inputarray = new int[datatype][65];          //  data files arranged characters, first 64 values corresponding 1 4x4 area ,         //  65th corresponds character class. combination loops writes input file array.         //  class zeroth element , 1st-64th elements divided pixel areas.         ( int = 0; <= datatype; i++ ){             ( int j = 1; j <= 65; j++ ){                 while( !input.hasnextint() ){                     input.next();                 }                 inputarray[i][j] = input.nextint();             }             while( !input.hasnextint() ){                 input.next();             }             inputarray[i][0] = input.nextint();         }           // when program exits 2 previous "for" loops program has finished reading         // scanner, "input", , scanner closed.         input.close();         system.out.println("file read in.");          return inputarray;     }     catch (ioexception error){          // if "try" block fails due file not being found, exception thrown.           system.out.println("file name not recognised. blank array has been produced.");          // array of zeroes created         inputarray = new int[datatype][65];          return inputarray;     } } 

thanks!

(if helps i'm using eclipse luna service release 2 (4.4.2))


Comments

Popular posts from this blog

how to insert data php javascript mysql with multiple array session 2 -

multithreading - Exception in Application constructor -

windows - CertCreateCertificateContext returns CRYPT_E_ASN1_BADTAG / 8009310b -