File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes I/O and Streams and the fly likes Writing back to JAR file? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "Writing back to JAR file?" Watch "Writing back to JAR file?" New topic
Author

Writing back to JAR file?

Roshni Singhania
Ranch Hand

Joined: Mar 11, 2007
Posts: 78
Hi,

I have a new query. I have been working on a project, which is working satisfactorily so far. This program needs to read and write data from text files. After finishing the coding, I was trying to package the program as a JAR File. I know how to read data from a text file packaged inside a JAR file, so that was no problem. But I didn't know what to do to WRITE data to the JAR! No such method in the JarFile API, either.

I need to know if there's any way at all to WRITE data back to the file (which is in the JAR). I didn't find anything on google that would help me. On one site, someone said that it might not be possible. I searched this site also. I wasn't able find anything about how to modify a text file within a JAR file. Has anyone ever done this? Is there any way at all to write/modify text files inside the JAR? Any ideas/suggestions are really appreciated. Thanks in advance!
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18991
    
    8

No, it's impossible to do that. A JAR file (and a ZIP file) is essentially a read-only archive.
Roshni Singhania
Ranch Hand

Joined: Mar 11, 2007
Posts: 78
Hi,

Thanks for answering.

So the only way is to carry the required files around, along with the JAR file.. that's the only way I suppose?
Nitesh Kant
Bartender

Joined: Feb 25, 2007
Posts: 1638

Roshni:
So the only way is to carry the required files around, along with the JAR file.. that's the only way I suppose?


Explode the jar on the file system, modify text files and then re-jar.


apigee, a better way to API!
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Writing back to JAR file?