I'm developping a Java Applet that must access the visitor's filesystem, so i compressed my .class file to a .jar file with self-signed cert, when I'm opening the call.html file with my browser (file where is located the <applet> HTML tag), I accept the security popup then i'm getting this error in the Java console:
java.security.AccessControlException: access denied (java.io.FilePermission output.txt write)
I'm using a FileInputStream and a FileOutputStream. FileInputStream works but not FileOutputStream, why?
Here's my code:
try {
AccessController.doPrivileged(
new PrivilegedExceptionAction() {
@Override
public Object run() throws FileNotFoundException {
outFile = new FileOutputStream("output.txt");
inFile = new FileInputStream("input.txt");
return "test";
}
}
);
} catch (PrivilegedActionException e) {
throw (FileNotFoundException) e.getException();
}
I've tried many way to make privileged actions, FileInputStream is always working, whereas FileOutputStream isn't. output.txt is not read-only file.
user.home. It is a place that should be allowable for a trusted app. to write. What is in the output? (E.G. Game scores, the customer's billing record..) - Andrew Thompsonuser.home? Netbeans show me this error: "Cannot find symbol: user". - user1376701outFile = new FileOutputStream(System.getProperty("user.home")+"/output.txt");i'm getting this error: java.security.AccessControlException: access denied (java.util.PropertyPermission user.home read) - user1376701