This week's book giveaway is in the Java in General forum.
We're giving away four copies of Think Java: How to Think Like a Computer Scientist and have Allen B. Downey & Chris Mayfield on-line!
See this thread for details.
Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

read and write files using applet

 
navish kumar
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a applet basically made for a Game. I want to have a text file called hiscores which is accessed by this applet and writes the userid into this with this total no of moves made.
The applet is running fine but am not able to get the applet write into or read the file. It always says file not found.
reply me ASAP
 
Idly Vada
Ranch Hand
Posts: 135
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Due to security restrictions, applets can not direcly access local file system unless they are given permissions by the user.

To enable your applet to acess the file system, you should edit the policy files and give appropriate permissions.You can do this by using policytool command or manually edit policy files.Give FilePermission(read and write) to the text file. You can give permission based on the codebase and/or signed authority.
Other approaches are: store user statistics in local variables or on the server side.
 
Nelson Nadal
Ranch Hand
Posts: 170
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ive same problem. Even just reading the files in a certain directory, what do you mean policy file? is it the attribute of the file (read-only, archive ...) ? Thanks...
 
John Boyd-Rainey
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Assuming you want to store the data on the client:
I have a signed (but not certified) applet which happily reads and writes to the local disk, if the user agrees to let it by clicking "Yes" to the security warning while it is loading. www.i2Brain.com/appletI2Brain.html.
If you want to store the data on the server, you'll need a small CGI there to do it. Have a look at the URLConnection class and look it up in a search enging with the term "CGI".
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic