public static List < String > getFileAsLines ( String sFileName ) throws Exception { FileInputStream fIn = null ; BufferedReader fileReader = null ; try { //open the file fIn = new FileInputStream ( sFileName ) ; fileReader = new BufferedReader ( new InputStreamReader ( fIn ) ) ; //create a Vector for output ArrayList < String > output = new ArrayList < String > ( ) ; //read the file line by line, append lines to the Vector String line = null ; while ( ( line = fileReader . readLine ( ) ) != null ) { output . add ( line ) ; } return output ; } catch ( Exception e ) { throw e ; } finally { fIn . close ( ) ; fileReader . close ( ) ; } }
Returns the contents of an ASCII file as a List of Strings .