I am trying to load and store properties to a properties file over a website (http://www.dasolorfire.freehostia.com/). My goal is to edit a property in-game, and then save the new property.
Here is storing code:
URL url = new URL("http://www.dasolorfire.freehostia.com/config.properties");
prop.store(new FileOutputStream(url.getFile()), null);
The problem is that when I run this, nothing happens. Instead, it saves it it the C:/ drive. When I use prop.load(url.openSream());, it works. How do you use FileOutputStream to save the file over the internet.
If I can’t get it to work over the internet, how can I save it in a jar?
You don’t, unless you’ve mounted a file system over the internet, which you can do but probably isn’t what you’re actually doing.
To send data to the server, in the usual case you talk to some server process that’s been designed to do that (HTTP, FTP, SSH, etc.).
In your case, for instance, you might have a servlet container running as an HTTP server, and so use
HttpURLConnectionor similar toPOSTdata to a servlet, which would in turn update the config file. This also gives you a server-side opportunity to enforce security, which is important, as everything sent from a client is suspect until proven otherwise.