How to read, write file inside the JAR file?
Hi all,
I want to read the file inside the jar file, use following method:
File file = new File("filename");
........
.......
It works if not in JAR file, but it doesn't work if it's in a JAR file.
I found someone had the same problem, but no reply.
http://forum.java.sun.com/thread.jsp?forum=22&thread=180618
Can you help me ? I have tried this for all night !
Thanks in advance
Leo
[463 byte] By [
LuckyLeo] at [2007-9-26 13:37:47]

> If you want to read a file from the JAR file that the
> application is packaged in (rather than a separate
> external JAR file) you do it like this ...
>
> InputStream is =
> ClassLoader.getSystemResourceAsStream("filename");
Better to use
this.getClass().getClassLoader().getResourceAsStream();
From a class near to where the data is. This deals with multiple classloaders properly.
slo at 2007-7-2 14:17:50 >
