Results 1 to 3 of 3
Thread: Clear InputStream Cache
- 02-07-2011, 11:24 PM #1
Member
- Join Date
- Feb 2011
- Posts
- 5
- Rep Power
- 0
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.
Java Code:public Map<String, String> extractAndLoadConfigurationFile() throws IOException, FileNotFoundException { String fFinalFile = ("PromoteMatches.properties"); InputStream is=null; 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(); try { p.load(is); is.close(); for (Iterator< ? > iterator = p.keySet().iterator(); iterator.hasNext();) ...
So how do you terminate this caching action on an input stream?
- 02-08-2011, 04:04 AM #2
Senior Member
- Join Date
- Jan 2009
- Posts
- 671
- Rep Power
- 5
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.
- 02-08-2011, 05:26 PM #3
Member
- Join Date
- Feb 2011
- Posts
- 5
- Rep Power
- 0
Similar Threads
-
Creating an InputStream
By c26354 in forum New To JavaReplies: 10Last Post: 07-12-2011, 04:48 AM -
InputStream problem
By javabarn in forum New To JavaReplies: 10Last Post: 06-29-2010, 04:09 PM -
How to clear cache of an Applet/JApplet
By tanmoy.b81 in forum AWT / SwingReplies: 0Last Post: 08-11-2008, 11:54 AM -
clear cache
By Jadellll in forum New To JavaReplies: 0Last Post: 03-20-2008, 09:27 AM -
JSP - using connection cache
By Java Tip in forum Java TipReplies: 0Last Post: 01-30-2008, 09:54 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks