I need to read/write on client machine. I followed this post and successfully got it to the point where the "Security Warning" message appears. But when I am making the call to Applet method from Javascript, I am getting the file permission error. I do not want to use Java Policy and use only signed applet. Is there any thing else required? I not very good at core Java and need some directions. Applet Code:
public class FileIo extends JApplet {
public void init(){
}
public static void main(String[] args) throws IOException {
FileIo obj = new FileIo();
obj.ReadFile(args[0]);
}
public String ReadFile(String fn) {
String thisLine, ret="";
try{
FileInputStream fin = new FileInputStream(fn);
BufferedReader myInput = new BufferedReader(new InputStreamReader(fin));
while ((thisLine = myInput.readLine()) != null) {
ret += thisLine + "\n";
}
}
catch(Exception e) {
ret = e.toString();
}
System.out.println(ret);
return ret;
}
}
HTML where Applet is added:
<script>
var attributes = {id: 'FileIoApplet',
codebase: '/webapp',
code: 'FileIo.class',
archive: 'FileIo.jar'};
var parameters = {java_arguments: '-Xmx256m'};
var version = '1.8'; // JDK version
deployJava.runApplet(attributes, parameters, version);
</script>
Javascript Call to Applet method:
alert(FileIoApplet.ReadFile('c:\\data\\info.txt'));
Following is the error that I get: