Hypothetically, say i want to know how may times anyone has clicked a button in an applet.

NOTE: this is not what i actually want to do but it is a good example.

more specifically i have a text file in a jar, along with classes, called clicks.txt. every time the button is clicked take the single number in the file add one to it and rewrite the new number back to the file.

is there any way to make something like this work?

this is what i am getting with a small test application:

Recommended Answers

All 10 Replies

No you cannot update text file inside the JAR. You can only created one with help of jar and then you can update it. However you facing main problem, what if user delete that file? JAR will create new one, but then you not getting accurate count

No you cannot update text file inside the JAR. You can only created one with help of jar and then you can update it. However you facing main problem, what if user delete that file? JAR will create new one, but then you not getting accurate count

so i cannot change a file, but i can make one, does that mean that i can read a file and then overwrite it with a new one? is this still all in the jar file, as in i can make a file still in the jar? if so how?

No, the new file which you create is outside the JAR file

what if it is an applet, is there a way to write a file to a web host, such as freewebs or googlepages?

Why to write to file if you can handle click count nicer on server side?

freewebs and googlepages don't allow server side code

what if it is an applet, is there a way to write a file to a web host, such as freewebs or googlepages?

I don't know about freewebs or googlepages but you can write a file on server if you have FTP access to the server where you want to write the file.

URL url = new URL("ftp://user:password@hostname");
URLConnection urlconnection = url.openConnection();

Use OutputStream to write a file on server.

Remember to sign your applet else it will not work when the applet is hosted online.

I don't know about freewebs or googlepages but you can write a file on server if you have FTP access to the server where you want to write the file.

URL url = new URL("ftp://user:password@hostname");
URLConnection urlconnection = url.openConnection();

Use OutputStream to write a file on server.

Remember to sign your applet else it will not work when the applet is hosted online.

i know freewebs doesn't allow FTP, i don't know about googlepages either,

i'm new to all this internet stuff, how do you sign an applet

thanks

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.