How can I write file in my PC

Tao, Wei (WTao@BreeceHill.com)
Thu, 2 Jul 1998 16:51:28 -0600

From: "Tao, Wei" <WTao@BreeceHill.com>
To: "'java-security@java.sun.com'" <java-security@java.sun.com>
Subject: How can I write file in my PC
Date: Thu, 2 Jul 1998 16:51:28 -0600

Dear Sir.

I have used JDK1.1.6 to compile my Java Applet and use both Internet
Explore 4.01 and Netscape Communicator 4.05 to run it. My JDK is
installed in my c:\JDK1.1.6 and the navigator.exe files is in the
c:\Program Files\Netscape\Communicator\Program. I had read the
decument of security FAQ. I understand that I should create the
directory /.hotjava/properties file and add acl.write=/.../file_name.
But after I did everything, it still can not do that, and show me
"writeFile:Caught Security exception" all the time. The example which
I am testing is from htttp://java.sun.com/sfaq/example/writeFile.html,
below is the code from that example, I hope you can give me some hand
and let me successful finish my project.

By the way, I am using WindowNT 4.0 workstation.

/**
* 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);
}

}
}


--Best wishes

--------------------------------------------------
Wei Tao
Software Engineer
Breece Hill Technologies
Voice : (303)449-2673 Ext 392
Pager : (303)528-3939
Cellular: (303)909-3504
email: wtao@breecehill.com
taow@colorado.edu
wtao436724@aol.com
web: http://www.breecehill.com

--------------------------------------------------
Wei Tao
Software Engineer
Breece Hill Technologies
Voice : (303)449-2673 Ext 392
Pager : (303)528-3939
Cellular: (303)909-3504
email: wtao@breecehill.com
taow@colorado.edu
wtao436724@aol.com
web: http://www.breecehill.com