This content has been marked as final. Show 12 replies
hello!There are a number of problems here.
i am creating an Applet game and I would like to
So, i need to take data from java and transfer them
into HTML. At my
university's book says that everytime we open a file
to write in it, if there are
already data, Java removes them and then writes the
new ones. But I want
a static file where Java can write the updated
rankings and HTML can take
them and use them in site. Is there any way to achive
If i wasn't clear, i just want a way to make Java not
to delete any data in a file
everytime it needs to write something in it!
First of all you can always append to a file, but that's not actually what you want to do.
Second you can read the whole file in, find the values you want, change them and write the whole file back. This is more of what you want to do but HTML is not the best choice for doing this.
But the most fundamental problem is that you do not write to files of any kind in an Applet.
oh...i can't write files in an Applet? it sounds weird to me! there are lots of
Java games over the internet with Rankings and Scores and stuff like that...
somehow they are writing files...or maybe they use a way I don't know?
i am not an expert in Java (i'm new in fact) so i might don't know the correct
way to do what i want to do. But I strongly believe that there should be a way
because it's a common thing!
oh...i can't write files in an Applet?No*
weird to me! there are lots of
Java games over the internet with Rankings and Scores
and stuff like that...
somehow they are writing files
...or maybe they use aYes.
way I don't know?
They are sending data back to the webserver through a Socket.
This would be the preferred way of doing it.
* - Technically you can write to files in an Applet BUT you must sign your applet and request permission to do so, this is involved. Further I get the strong feeling it doesn't do what you want anyway. If you want to save a high score you will not be writing to the HTML file. This is not the way the internet works.
my book didn't mention that boolean indicatingAppend will not help you.
whether or not append the
data written in file...so that boolean takes True to
keep data and write the new
after them and False to delete everything and write
the new data? or the opposite?
Append true - to keep data and add (append) new data.
But it won't help. Think about what appending data to an HTML file means.... not changing. Appending/adding
i will not write in an HTML file! just a .txt andThen don't use an Applet!
then i will have HTML code that
will go and read that .txt! everything is gonna
happen localy...it's just an
Assignment for my university...that game will not go
online or something!
Or post the data back to the server using HttpURLConnection (recommended).