/** * With Netscape Navigator 2.0, this always raises security exception. * * With JDK 1.0 appletviewer, * this raises security exception by default. * However if you add /tmp (or the file /tmp/foo) to acl.write, then * applets loaded over the net can read files in /tmp (or the file /tmp/foo.) * * Applets installed on your local file system in a directory on * your CLASSPATH can write files on your local file system, * from the appletviewer, regardless of the setting of acl.write. * * @version JDK 1.0 beta * @author Marianne Mueller */ import java.awt.*; import java.io.*; import java.lang.*; import java.applet.*; public class writeFile extends Applet { String myFile = "/tmp/foo"; File f = new File(myFile); DataOutputStream dos; public void paint(Graphics g) { try { dos = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(myFile),128)); dos.writeChars("Cats can hypnotize you when you least expect it\n"); dos.flush(); g.drawString("Successful attempt to write to " + myFile, 10, 10); } catch (SecurityException e) { g.drawString("writeFile: caught security exception", 10, 10); } catch (IOException ioe) { g.drawString("writeFile: caught i/o exception", 10, 10); } } }