public static InputStream getRequiredResourceAsStream ( Class < ? > clzz , String location ) { InputStream resourceStream = clzz . getResourceAsStream ( location ) ; if ( resourceStream == null ) { // Try with a leading "/" if ( ! location . startsWith ( "/" ) ) { resourceStream = clzz . getResourceAsStream ( "/" + location ) ; } if ( resourceStream == null ) { throw new RuntimeException ( "Resource file was not found at location " + location ) ; } } return resourceStream ; }
Return an InputStream of the specified resource failing if it can t be found .