【发布时间】:2011-02-01 04:07:38
【问题描述】:
我编写了一个简单的 Java 小程序来根据 CSV 文件中的一些数据生成技术图像。我将 CSV 文件作为参数传递给小程序:
<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>
据我了解小程序安全限制,小程序应该能够从它们所在的主机读取数据。
http://www.jalview.org/examples/applets.html 中的这些小程序使用相同的方法,将文本数据文件作为参数传递。所以我不确定为什么我自己的小程序不起作用。
我正在使用 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;
}
我收到的错误消息是:
Error with processing the CSV data.
java.security.AccessControlException: access denied (java.io.FilePermission http:\localhost\applet_test\test.csv read)
【问题讨论】:
-
您能否提供一些代码供您阅读。您阅读它的方式可能会有所不同。
-
我已经在实际读取文件的地方添加了代码。
标签: java applet file-permissions