/** * 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 ~/.hotjava (or the file ~/.hotjava/properties) * to acl.write, then applets loaded over the net can change your * properties file. * * Note that under no circumentances should you allow this! * That is, never add ~/.hotjava or ~/.hotjava/properties to * your acl.write list. If you do, then applets loaded over * the net will be able to change your browser properties to * allow themselves to read and write to any files on your system. * * @version JDK 1.0 beta * @author Marianne Mueller */ import java.awt.*; import java.io.*; import java.lang.*; import java.applet.*; public class replacePropertiesFile extends Applet { String myFile = "/home/mrm/.hotjava/properties"; File f = new File(myFile); DataOutputStream dos; public void paint(Graphics g) { try { dos = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(myFile),128)); dos.writeChars("acl.write=/tmp\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); } } }