on 01-08-2007 9:07 AM
Hi,
I am accessing one Random Access File through Java Mapping Program. This is working fine in Eclipse.
But when I imported that jar file to IR, it is throwing FileNotFound Exception while trying to test through Interface Mapping.
I have bundled the file in the jar file, where the java class file is bundled.
Path to access the file from java program is "ProjectName/SomeName/File_Name.txt"
Can any one please help me in this regard?
Please help me to chase this mistery.
Thanks,
Yogi.
hello yogen,
once your file (or images) are inside a jar file, it cannot be accessed just like a
file. it is now a resource... to read a resource, try this simple reader.
InputStream is = getClass().getResourceAsStream(fileName);
InputStreamReader isr = new InputStreamReader(is);
BufferedReader br = new BufferedReader(isr);
regards
jo
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi yogen,
unfortunately you won't be able to directly write into a file that is within the jar file.
jar files are just like zip files and the files are compressed. you need to extract the
jar file, access and write the file, and re-zip (or jar) it once again. programmatically
this is possible, but you have to know the path of that jar file. if you are to modify
a file from your program, i would suggest not to include it inside a jar file. rather
put it outside to be accessed easily.
regards
jo
User | Count |
---|---|
91 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.