...

View Full Version : JAVA Applet: write to file



VietBoyVS
09-16-2004, 05:11 PM
import java.io.*;

public class WriteIt {
public boolean writeFile(String text, String fileID) {
try {
File file = new File(fileID);
FileWriter fWriter = new FileWriter(file);
fWriter.write(text);
fWriter.close();
return true;
} catch(IOException e) {
return false;
}
}
}


Welcome to DrJava.
> WriteIt a = new WriteIt();

> a.writeFile("AAAAAAAAAAAAXXX","C:\\folder 1\\x x\\dfjs.txt")

true

> a.writeFile("AAAAAAAAAAAAXXX","C:\\Documents and Settings\\Admin\\Desktop\\dfjs.txt")

true

> a.writeFile("AAAAAAAAAAAAXXX","dfjs.txt")

The above class works fine, and that is what I expected.

Should these to work for JApplet too? sinc I call these to write it to my "C:\\folder 1\\a.txt" for testing. no success

any help?

shmoove
09-18-2004, 05:40 PM
Writing to the local file system would be a violation of the applet's security model. You might be able to accomplish it with a signed applet. But you're better off just saving the file on the server.

shmoove

VietBoyVS
09-18-2004, 06:49 PM
how do a signed the applet?

If we have a web server, we can run servlet for free?



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum