• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

writing back to jar file ??

 
Ranch Hand
Posts: 305
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,
My question is:-
1. I have a jar file say "test.jar"
2. This jar file contains a file say abc.txt, which has been written using ObjectOutputStream and ObjectInputStream.
3. I have to give an option where when user clicks this option it will go to my server through URL connection and get some information again as an object format.
4. I have to update this String object into the abc.txt file of test.jar.
My question is How?
I tried exploring the JavaOutputStream class but could not able to understand how to use this... can you please help me..
Regards,
Arun
 
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think maybe you are trying to make this too difficult. But I have to ask a question or 2.
Are you having a problem with basic I/O in JAVA or Is your problem with how to write to a file that exists inside a JAR file?
If the latter is true, then is your java program running from the same JAR file that the txt file exists? If this is true then just do your basic I/O for that file. A jar file is just a directory structure. So your applicaion will treat the files inside it just like any other file on the Hard Drive. For instance, if your JAR file is set up thusly:
classes/*.class
images/*.gif *.jpeg, etc
manafest
text/*.txt
Then you want to create a File object for a txt file:
File file = new File("/text/test.txt");
Now, if on the other hand your text files are contained outside of your app but still in a JAR file you will need to use a class Loader to get inside the JAR file and open them.
If you are having problems with Basic Java I/O I would suggest postsing some code you are using for your I/O operations and/or post a question in the Java I/O forum maybe.
Hope that helps a little.
 
arun mahajan
Ranch Hand
Posts: 305
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Gregg for your reply... I was trying with following codes but in vain. any other suggestion:-


Both the code snippet is giving me following error:
Error from update++++: java.io.FileNotFoundException: file:/E:/test/insta.jar!/m
odel.ins (The filename, directory name, or volume label syntax is incorrect)
 
arun mahajan
Ranch Hand
Posts: 305
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Any Thoughts for this...Perhaps there should be something like setResource in the API..I am asking too much...
regards,
Arun
 
arun mahajan
Ranch Hand
Posts: 305
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I tried with another set of code for writing a file back into the jar file..but surprisingly it works as a regular file writing..what i mean to say it makes a file but outside of the jar file...
can somebody give me a lead? Perhaps Mr. bartender can lend me a helping hand for this :-)
regards,
Arun
 
arun mahajan
Ranch Hand
Posts: 305
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I tried finding an answer for this question on every possible place and perhaps tried all possibilities...and my only hope is this forum...
And I therefore request all the people to please let me know where I am wrong...Am I doing something very foolishly somewhere?..Is there any workaround for it..Please help me, if possible.
regards,
arun
[ June 27, 2002: Message edited by: arun mahajan ]
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic