public static String [ ] readListFile ( URL listFile ) throws IOException { ArrayList < String > list = new ArrayList < String > ( ) ; InputStream stream = listFile . openStream ( ) ; try { InputStreamReader isr = new InputStreamReader ( stream , "UTF-8" ) ; BufferedReader reader = new BufferedReader ( isr ) ; String line = reader . readLine ( ) ; while ( line != null ) { list . add ( line ) ; line = reader . readLine ( ) ; } String [ ] items = new String [ list . size ( ) ] ; list . toArray ( items ) ; return items ; } finally { stream . close ( ) ; } }
Read a file and return the list of lines in an array of strings .