static Set < String > readServiceFile ( InputStream input ) throws IOException { HashSet < String > serviceClasses = new HashSet < String > ( ) ; Closer closer = Closer . create ( ) ; try { // TODO(gak): use CharStreams BufferedReader r = closer . register ( new BufferedReader ( new InputStreamReader ( input , UTF_8 ) ) ) ; String line ; while ( ( line = r . readLine ( ) ) != null ) { int commentStart = line . indexOf ( ' ' ) ; if ( commentStart >= 0 ) { line = line . substring ( 0 , commentStart ) ; } line = line . trim ( ) ; if ( ! line . isEmpty ( ) ) { serviceClasses . add ( line ) ; } } return serviceClasses ; } catch ( Throwable t ) { throw closer . rethrow ( t ) ; } finally { closer . close ( ) ; } }
Reads the set of service classes from a service file .