private InputStream getResourceAsStream ( String resource ) { InputStream is = getClass ( ) . getResourceAsStream ( resource ) ; // switch needed for testability if ( is == null ) { try { is = new FileInputStream ( new File ( resource ) ) ; } catch ( FileNotFoundException e ) { // do nothing } } if ( is == null ) { throw new SelendroidException ( "The resource '" + resource + "' was not found." ) ; } return is ; }
Loads resources as stream and the main reason for having the method is because it can be use while testing and in production for loading files from within jar file .