Example usage for javax.servlet ServletContext getResourceAsStream

List of usage examples for javax.servlet ServletContext getResourceAsStream

Introduction

In this page you can find the example usage for javax.servlet ServletContext getResourceAsStream.

Prototype

public InputStream getResourceAsStream(String path);

Source Link

Document

Returns the resource located at the named path as an InputStream object.

Usage

From source file:org.apache.catalina.core.StandardContext.java

/** JSR77 deploymentDescriptor attribute
 *
 * @return string deployment descriptor 
 *///from   w ww. ja  v  a  2s.com
public String getDeploymentDescriptor() {

    InputStream stream = null;
    ServletContext servletContext = getServletContext();
    if (servletContext != null) {
        stream = servletContext.getResourceAsStream(org.apache.catalina.startup.Constants.ApplicationWebXml);
    }
    if (stream == null) {
        return "";
    }
    BufferedReader br = new BufferedReader(new InputStreamReader(stream));
    StringBuffer sb = new StringBuffer();
    String strRead = "";
    try {
        while (strRead != null) {
            sb.append(strRead);
            strRead = br.readLine();
        }
    } catch (IOException e) {
        return "";
    }

    return sb.toString();

}