static ArrayList<String> loadImage(File file) throws FileNotFoundException, RuntimeException {
  if (file == null)   return null;
  Scanner sc;
  sc=new Scanner(file);
  ArrayList<String> rows=new ArrayList<String>();
  String s=sc.nextLine();
  int len=s.length();
  int idx=1;
  rows.add(s);
  while (sc.hasNext()) {
    idx++;
    s=sc.nextLine();
    if (s.length() != len) {
      sc.close();
      throw new RuntimeException("Line " + idx + " only has "+ s.length()+ " characters (should have "+ len+ ")");
    }
    rows.add(s);
  }
  sc.close();
  return rows;
}

static ArrayList < String > loadImage ( File file ) throws FileNotFoundException , RuntimeException { if ( file == null ) return null ; Scanner sc ; sc = new Scanner ( file ) ; ArrayList < String > rows = new ArrayList < String > ( ) ; String s = sc . nextLine ( ) ; int len = s . length ( ) ; int idx = 1 ; rows . add ( s ) ; while ( sc . hasNext ( ) ) { idx ++ ; s = sc . nextLine ( ) ; if ( s . length ( ) != len ) { sc . close ( ) ; throw new RuntimeException ( "Line " + idx + " only has " + s . length ( ) + " characters (should have " + len + ")" ) ; } rows . add ( s ) ; } sc . close ( ) ; return rows ; }
helper function to load up images .
