Jump to content
  • Advertisement
Sign in to follow this  
Swattkidd

[java] Writing to a file at a URL help

This topic is 4101 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Ok i am creating a chat type of program that reads info from a file and posts it, but the problem i am haveing is being able to write to the file. The file is located in my site so i can read from it by reading from a URL but im not sure how to write to the URL, like send what the person writes in the chat box to the file when they push enter...

Share this post


Link to post
Share on other sites
Advertisement
No im trying to write to it the way i read from it, by makeing a URL and then opening a connection with it, but im not very clear on that, right now im asking how i could do that. I dont want to make it a networked chat program yet. I just want it so that a person opens it up and it displays what the last person wrote (because it displays whats in the txt doc) and then they can type, push send, and now when another person opens it, they can see what that person wrote (because its stored in the txt doc)

Share this post


Link to post
Share on other sites
Writing to the file that is on the server side should be the responsibility of an (web) application residing on that server. If you want to write to a file from remote code, you have to require the necessary permissions in a .policy file, and that can be a pain to configure and make work. I suggest you write a Servlet or something that deals with the writing, and let it receive as parameters what needs to be written on the file. Delegate different responsibilities to different classes in your architecture, making your system as 'loose coupled' as possible.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
If you were to connect to the server via ftp and modify the file. The client would also need to have the username + password data. Thus, for security reasons would be a very bad idea. Simple decompiling of your application would reveal everything since, java is so easy to decompile anyone could do it.

Connect to a server, servlet, use a post() or get() statement for PHP to handle. and let the server deal with the modifying of the file.

Share this post


Link to post
Share on other sites
Ok thanks guys, all in all ive realized my simple way of getting around networking was not so simple, so i decided to learn networking :) thanks for the advice and help!

Share this post


Link to post
Share on other sites
Hi

I got the same problem, did you get any solutaion, if yes, could you please post it on this forum. I have need to do the same thing.

Regards
Lucky

Share this post


Link to post
Share on other sites
No man i havent found a solution, im just learning normal networking instead..but you might be able to write to a file using servlets ;)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!