How to get lastModified time of a file within a jar file on the classpath?
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Alan_Gault
Posted On:   Friday, January 11, 2002 09:39 AM

I have a file within a jar file on the classpath and I want its lastModified time. I can get an InputStream using Class.getResourceAsStream, but how can I go from InputStream to File in order to get the lastModified time. Can I just use the lastModified time of the jar file, and if so, how do I get that off the classpath?

Thanks.

Re: How to get lastModified time of a file within a jar file on the classpath?

Posted By:   Jens_Dibbern  
Posted On:   Thursday, January 17, 2002 11:40 PM

If you know the jar file, you can open it as a java.util.jar.JarFile object and use getJarEntry to retrieve the file in question as a java.util.jar.JarEntry object. After that you can call getTime.

If you do not know the jar file, you have to get the classpath by String classPath = System.getProperty("java.class.path"); and try every jar file included.

Sorry about the last bit - I know it looks quite clumsy.
About | Sitemap | Contact