public static String getVersion ( String path , Class < ? > klass ) { try { final InputStream in = klass . getClassLoader ( ) . getResourceAsStream ( path ) ; if ( in != null ) { try { final BufferedReader reader = new BufferedReader ( new InputStreamReader ( in ) ) ; String line = reader . readLine ( ) ; while ( line != null ) { if ( line . startsWith ( "version" ) ) { return line . split ( "=" ) [ 1 ] ; } line = reader . readLine ( ) ; } } finally { in . close ( ) ; } } } catch ( IOException e ) { LOG . error ( "Could not read package version using path " + path + ":" , e ) ; } return "unknown" ; }
Attempts to get a version property from a specified resource