Clear InputStream Cache
I know this has got to be a common problem but so far I havent found any references to this issue:
I have a small method thats supposed to open a parameter file as an inputStream, read the contents into a Parameter array and then close the stream; but after the first open/read/close sequence it seems to be caching the information because even if I delete the file the method still returns its previous contents.
public Map<String, String> extractAndLoadConfigurationFile() throws IOException, FileNotFoundException
String fFinalFile = ("PromoteMatches.properties");
Map<String, String> fMergedProps=new HashMap<String,String>();
is = getClass().getClassLoader().getResourceAsStream(fFinalFile);
log.debug("property file loaded through standard getClass.getClassloader: " + (is != null));
if (is != null)
Properties p = new Properties();
for (Iterator< ? > iterator = p.keySet().iterator(); iterator.hasNext();)
So how do you terminate this caching action on an input stream?
I think the issue is that the classloader caches resources. I can't think of any way to cause it to reload a resource.
The idea behind class resources is that they are static, so what you are trying to do is probably unsupported in any way. You would probably be better served to load the file using a FileInputStream.
Thanks Toadaly - I did think of switching input methods but wasnt sure which other one to choose. I am fairly new to Java and your lead helps a lot.