private InputStream getStreamForLocation(final String location, final ServletContext context) throws FileNotFoundException {
        String fileLocation = StringUtils.replaceVariables(location, new HashMap<String, Object>(), true);  
           if (fileLocation.startsWith(PREFIX_FILE)) {
              return new FileInputStream(fileLocation.substring(PREFIX_FILE.length()));
           } else if (fileLocation.startsWith(PREFIX_CLASSPATH)){ 
                  return getClass().getResourceAsStream(fileLocation.substring(PREFIX_CLASSPATH.length()));
           } else {
               if (fileLocation.startsWith(PREFIX_WAR)) {
                   fileLocation = fileLocation.substring(PREFIX_WAR.length());
               }
              return context.getResourceAsStream(fileLocation);
           }  
    }
private InputStream getStreamForLocation ( final String location , final ServletContext context ) throws FileNotFoundException { String fileLocation = StringUtils . replaceVariables ( location , new HashMap < String , Object > ( ) , true ) ; if ( fileLocation . startsWith ( PREFIX_FILE ) ) { return new FileInputStream ( fileLocation . substring ( PREFIX_FILE . length ( ) ) ) ; } else if ( fileLocation . startsWith ( PREFIX_CLASSPATH ) ) { return getClass ( ) . getResourceAsStream ( fileLocation . substring ( PREFIX_CLASSPATH . length ( ) ) ) ; } else { if ( fileLocation . startsWith ( PREFIX_WAR ) ) { fileLocation = fileLocation . substring ( PREFIX_WAR . length ( ) ) ; } return context . getResourceAsStream ( fileLocation ) ; } }
Returns the InputStream to the supplied file location

@param location  File location, may contain file:, classpath: or war: prefix. If no prefix is used war location is assumed.
@param context  Servlet Context to read war resources from.

@throws FileNotFoundException If a file resource could not be found.