我已經編寫了一個簡單的Java小應用程序,用於根據CSV文件中的某些數據生成技術圖像。我傳遞的CSV文件作爲參數傳遞給小程序:Java小應用程序 - 在同一Web服務器上拒絕訪問的訪問
<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>
據我瞭解applet的安全限制,一個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)
你能提供一些你的閱讀代碼嗎?你如何閱讀它可能會有所作爲。 – justkt 2010-03-26 12:52:12
我已經添加了我實際讀取文件的代碼。 – 2010-03-26 13:00:18