我编写了一个简单的Java小程序,用于根据CSV文件中的某些数据生成技术图像.我将CSV文件作为参数传递给applet:
<applet code = "assaymap.AssayMapApplet" archive = "http://localhost/applet_test/AssayMap.jar" height="600px" width="800px">
<param name="csvFile" value="http://localhost/applet_test/test.csv">
</applet>
Run Code Online (Sandbox Code Playgroud)
据我了解applet安全限制,applet应该能够从他们所在的主机读取数据.
这些applet http://www.jalview.org/examples/applets.html使用相同的方法传递文本数据文件作为参数.所以我不确定为什么我自己的applet不起作用.
我正在使用sourceforge上的javacsv项目读取文件.
我读取CSV文件的代码是:
public static ArrayList<Assay> getData(String file) throws FileNotFoundException, IOException {
ArrayList<Assay> assays = new ArrayList<Assay>();
CsvReader reader = new CsvReader(file);
reader.readHeaders();
while (reader.readRecord()){
int assay_id = Integer.valueOf(reader.get("assay_id"));
String assay_name = reader.get("assay_name");
float distance = Float.parseFloat(reader.get("distance"));
assays.add(new Assay(assay_id, assay_name, distance));
}
return assays;
}
Run Code Online (Sandbox Code Playgroud)
我抛出的错误信息是:
Error with processing the CSV data.
java.security.AccessControlException: access denied (java.io.FilePermission http:\localhost\applet_test\test.csv read)
Run Code Online (Sandbox Code Playgroud)