Java Applets – Can it read and write files?
In Java-enabled browsers, untrusted applets cannot read or write files at all. By default, downloaded applets are considered untrusted. There are two ways for an applet to be considered trusted:
The applet is installed on the local hard disk, in a directory on the CLASSPATH used by the program that you are using to run the applet. Usually, this is a Java-enabled browser, but it could be the appletviewer, or other Java programs that know how to load applets.
The applet is signed by an identity marked as trusted in your identity database. For more information on signed applets, refer to an example of using signed applets, and to a short description on using javakey.
Sun’s appletviewer allows applets to read files that reside in directories on the access control lists.
If the file is not on the client’s access control list, then applets cannot access the file in any way. Specifically, applets cannot
- check for the existence of the file
- read the file
- write the file
- rename the file
- create a directory on the client file system
- list the files in this file (as if it were a directory)
- check the file’s type
- check the timestamp when the file was last modified
- check the file’s size