public static List < String > loadOptions ( String optionFileName ) { List < String > args = new ArrayList < String > ( ) ; File optionFile = new File ( optionFileName ) ; StringWriter stringWriter = new StringWriter ( ) ; try { InputStream inputStream = new FileInputStream ( optionFile ) ; IOUtils . copy ( inputStream , stringWriter ) ; } catch ( FileNotFoundException e ) { System . err . println ( "Error reading options file: " + e . getMessage ( ) ) ; System . exit ( 1 ) ; } catch ( IOException e ) { System . err . println ( "Error reading options file: " + e . getMessage ( ) ) ; System . exit ( 1 ) ; } String string = stringWriter . toString ( ) ; StringTokenizer stringTokenizer = new StringTokenizer ( string ) ; while ( stringTokenizer . hasMoreTokens ( ) ) { args . add ( stringTokenizer . nextToken ( ) ) ; } return args ; }
Load options from a file