.getClassLoader().getResourceAsStream(path) caches result
<p>I load a file at a servlet, use .getClassLoader().getResourceAsStream(path), path is in WEB-INF/classes dir, I found after I changed path file content, but file servlet loads are the same, don't change, file is cached.</p>

<p>example code:</p>

<p>This method always gets the same result every time, after I change the test.key content</p>

<pre><code>private String getKey(String param){
    String name = "keys/"+param+"/test.key";
    InputStream in = XXXServlet.class.getClassLoader().getResourceAsStream(name);
    StringBuilder builder = new StringBuilder();
    try {
        BufferedReader reader = new BufferedReader(new InputStreamReader(in));
        String line = null;
        while((line = reader.readLine()) != null){
            builder.append(line).append("\n");
        }
    } catch (IOException ignoreException) {

    }finally{
        try {
            in.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    String result = builder.toString();
    return result;
}
</code></pre>

<p>=================================================================</p>

<p>change these two lines code, it works fine</p>

<pre><code>    String name = "/WEB-INF/classes/keys/"+param+"/test.key";
    InputStream in = getServletContext().getResourceAsStream(name);
</code></pre>
