【发布时间】:2014-01-04 22:17:59
【问题描述】:
我有一个在客户端读取文件的小程序。
public class MyApplet extends Applet {
public static void main(String[] args){
JFrame frame = new JFrame();
MyApplet inst = new MyApplet();
frame.getContentPane().add(inst);
((JComponent)frame.getContentPane()).setPreferredSize(inst.getSize());
frame.pack();
frame.setVisible(true);
}
public MyApplet(){
initGUI();
}
public String readFile() {
String thisLine, ret = "";
String fn="c:\\1\\a.txt";
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();
}
return ret;
}
}
我遇到的异常
java.security.AccessControlException: access denied ("java.io.FilePermission" "c:\1\a.txt" "read")
请帮帮我 我签了小程序
【问题讨论】:
标签: java permissions applet