I am trying to build a java applet which downloads a file to the client machine. As a java application this code worked fine but when I tried as an applet it does nothing. I
FileOutputStream fos = new FileOutputStream("google.html");
Change that to:
File userHome = new File(System.getProperty("user.home"));
File pageOutput = new File(userHome, "google.html");
FileOutputStream fos = new FileOutputStream(pageOutput); //see alternative below
Ideally you would put the output in either of:
user.home
. user.home
is a place where the user is supposed to be able to read & create files. JFileChooser
.See this question,
Self Signed Applet Can it access Local File Systems
I believe it will help you, you need to write your code to use PrivilegedAction.
http://docs.oracle.com/javase/1.4.2/docs/api/java/security/PrivilegedAction.html