wood burning stoves*
The moose likes Applets and the fly likes Writing to a file from an Applet using IE5, can it be done Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Applets
Bookmark "Writing to a file from an Applet using IE5, can it be done" Watch "Writing to a file from an Applet using IE5, can it be done" New topic

Writing to a file from an Applet using IE5, can it be done

Martin Lawrence

Joined: Oct 20, 2000
Posts: 14
Hi All,
I attempted to run the following code via IE5 after building it
under JDK1.3. I got a security exception.
I created a Ploicy file using the standard policytool command.
I set the policy settings as :-
FilePermission java.io.FilePermission
Target Name << <<ALL FILES>> >>
Actions read, write, delete, execute
I saved the policy file as mypolicy under directory
The above directory also contains WriteFile.java, WriteFile.class
and JavaSecurity.html.
I also added the following line:-
within file java.security within directory:-
import java.awt.*;
import java.io.*;
import java.lang.*;
import java.applet.*;
public class WriteFile extends Applet {
String myFile = "writetest";
File f = new File(myFile);
DataOutputStream dos;
public void init() {

String osname = System.getProperty("os.name");
public void paint(Graphics g) {
System.out.println("Start of paint");
try {
dos = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(myFile),128));
dos.writeChars("Cats can hypnotize you when you least expect it\n");
g.drawString("Successfully wrote to the file named " + myFile + " -- go take a look at it!", 10, 10);
catch (SecurityException e) {
g.drawString("writeFile: caught security exception: " + e, 10, 10);
catch (IOException ioe) {
g.drawString("writeFile: caught i/o exception", 10, 10);
System.out.println("End of paint");
<TITLE>Java Security Model</TITLE>
<APPLET CODE="WriteFile.class" WIDTH="150" Height="25">

Help, is it possible to read/write to a file via an applet using IE5 ???
Rahul Rathore
Ranch Hand

Joined: Sep 30, 2000
Posts: 324
NO that won't work.
What you need to do is to use the JDK plug-in to your browser and configure the security setting there. And you have to use signed applets. It is a long story, but you can find it in any good book like Core Java, and I think on this ranch in some post.
I agree. Here's the link: http://aspose.com/file-tools
subject: Writing to a file from an Applet using IE5, can it be done
Similar Threads
file write
Applet with RMI ,how to place into Tomcat?
Writing to a file
applet and the html file in separate directory
another signed applet question