public static String getAbsolutePath ( String classPath ) { URL configUrl = Thread . currentThread ( ) . getContextClassLoader ( ) . getResource ( classPath . substring ( 1 ) ) ; if ( configUrl == null ) { configUrl = ResourceUtil . class . getResource ( classPath ) ; } if ( configUrl == null ) { return null ; } try { return configUrl . toURI ( ) . getPath ( ) ; } catch ( URISyntaxException e ) { throw new RuntimeException ( e ) ; } }
Get absolute path in file system from a classPath . If this resource not exists return null .