Reading text file and skipping blank lines until EOF is reached
I am trying to read csv file full of text; however if there is a blank line in the middle somewhere, the whole thing breaks and I get a: java.lang.RuntimeException: java.lang.StringIndexOutOfBoundsException How would I go about removing/ignoring blank lines as long as it's not the end of the file? file = new FileReader(fileName); @SuppressWarnings("resource") BufferedReader reader = new BufferedReader(file); while ((line = reader.readLine()) != null) { //do lots of stuff to sort the data into lists etc } } catch (Exception e) { System.out.println("INPUT DATA WAS NOT FOUND, PLEASE PLACE FILE