I would like to read a text file after the contents have changed, but Java is caching the original contents of the file.
I have tried URLConnection.setUsesCaches(false), which didn't help. I also tried adding a changing dummy query string parameter, but again no help
Resource[] resources = applicationContext.getResources("classpath*:/" + file);
for (Resource resource:resources) {
URL url = resource.getURL();
// reconstruct the URL to remove any possible vestiges of the resource
url = new URL(url.toString());
URLConnection conn = url.openConnection();
conn.setUseCaches(false); // Tried this first, but it did not work!
// url = new URL(url.toString() + "?dummy=" + id); // tried this also, but it doesn't work at all
InputStream inputStream = conn.getInputStream();
Is there any way to tell Java to re-read the new contents of a file?