how to write in a jar file

S

Sascha Dümichen

read with
Class c = this.getClass();
is = c.getResourceAsStream(filename);
isr = new InputStreamReader(is);

its ok, but i cannot use getRessourceAsStream by OutputStreamWriter

how can i write a highscore in a jar file?
not an extern file.

thx
 
A

Andrew Thompson

how can i write a highscore in a jar file?
not an extern file.

The only way to do that is to rewrite the
entire jar/zip file. Java does not offer
any form of 'random access' to compressed
files, as I do not think the underlying
format supports it.

But then, why on earth would you want to
store the high scores back into the jar file?
Put them in "user.home" and be done with it.

HTH
 
P

Paul Lutus

Sascha said:
read with
Class c = this.getClass();
is = c.getResourceAsStream(filename);
isr = new InputStreamReader(is);

its ok, but i cannot use getRessourceAsStream by OutputStreamWriter

how can i write a highscore in a jar file?

1. Unpack the jar.
2. Write to one of its files.
3. Repack it.

From the information in your post, I am reasonably sure you don't want to do
this. Create a high-score file external to the JAR file.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top