1

I've written a simple Java applet to generate a technical image based upon some data in a CSV file. I'm passing in the CSV file as a parameter to the 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>

As far as I understood applet security restrictions, an applet should be able to read data from the host they're on.

These applets here http://www.jalview.org/examples/applets.html are using the same approach of passing in a text data file as a parameter. So I'm not sure why my own applet isn't working.

I'm reading the file using the javacsv project on sourceforge.

My code for reading the CSV file is:

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;
}

The error message I get thrown is:

Error with processing the CSV data.
java.security.AccessControlException: access denied (java.io.FilePermission http:\localhost\applet_test\test.csv read)
2
  • 1
    Can you provide some code for your read. How you are reading it may make a difference. Commented Mar 26, 2010 at 12:52
  • I've added the code where I actually read the file. Commented Mar 26, 2010 at 13:00

1 Answer 1

5

You are obviously trying to use "http://localhost/applet_test/test.csv" as a file name and not as a URL. Take a look at the URL and URLConnection classes in the java.net package and use these to read the content instead of java.io.File.

Sign up to request clarification or add additional context in comments.

1 Comment

Thansk very much. I'm now passing an InputStream generated from the URL into CsvReader and it's working perfectly.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.