4 Replies - 454 Views - Last Post: 26 August 2011 - 02:44 PM Rate Topic: -----

#1 christoi  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 26-August 11

Is it possible to create a text file inside a .jar?

Posted 26 August 2011 - 01:26 PM

Hello!
I've been tring to create a program that can create, read and write text files inside an executable jar file. However, upon searching on google, I've found mixed answers, some saying it's possible, others saying it isn't. I couldn't seem to find any code examples.

I'm trying to add a feature to my program that it saves files directly inside itself, to make the files management easier for the user. Is this possible? If not, are there any other options?

Thanks in advance. :)

Is This A Good Question/Topic? 0
  • +

Replies To: Is it possible to create a text file inside a .jar?

#2 Dogstopper  Icon User is offline

  • The Ninjaducky
  • member icon



Reputation: 2871
  • View blog
  • Posts: 11,026
  • Joined: 15-July 08

Re: Is it possible to create a text file inside a .jar?

Posted 26 August 2011 - 01:29 PM

I know that you can read them. I also think that you can write them, but you have to use a rounabout method where you create a file, then use java.util.zip Classes to halp wrap them up into ZIP file (which can also be JARs). As for the same JAR, I do not know.
Was This Post Helpful? 0
  • +
  • -

#3 christoi  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 26-August 11

Re: Is it possible to create a text file inside a .jar?

Posted 26 August 2011 - 01:38 PM

View PostDogstopper, on 26 August 2011 - 01:29 PM, said:

I know that you can read them. I also think that you can write them, but you have to use a rounabout method where you create a file, then use java.util.zip Classes to halp wrap them up into ZIP file (which can also be JARs). As for the same JAR, I do not know.

In that case, I think I may just try to stay with just creating a text file normally then. Since java can compress and decompress zip files, it still would be then relatively compact.

Thank you for the quick reply!

This post has been edited by christoi: 26 August 2011 - 01:38 PM

Was This Post Helpful? 0
  • +
  • -

#4 Dogstopper  Icon User is offline

  • The Ninjaducky
  • member icon



Reputation: 2871
  • View blog
  • Posts: 11,026
  • Joined: 15-July 08

Re: Is it possible to create a text file inside a .jar?

Posted 26 August 2011 - 01:48 PM

Glad I could help. If you have any more questions, feel free to ask.
Was This Post Helpful? 0
  • +
  • -

#5 g00se  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2687
  • View blog
  • Posts: 11,349
  • Joined: 20-September 08

Re: Is it possible to create a text file inside a .jar?

Posted 26 August 2011 - 02:44 PM

Not possible without nasty kludges, that might fail. Better to write to user.home
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1