Skip to Content
author's profile photo Former Member
Former Member

Accessing a File in a Java Mapping


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.



Add a comment
10|10000 characters needed characters exceeded

Related questions

1 Answer

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Jan 08, 2007 at 04:11 PM

    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);



    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      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.



Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.