java help plz--- reading in a file

spp

Golden Member
Jul 9, 2001
1,513
0
76
Hey all:

I'm kinda new to java programming, and I'm trying to read in a file from the same folder as the other files.

I've tried just using:
FileReader filereader = new FileReader("index.txt");

and also using:

filename = new String(parent.getCodeBase().toString() + "index.txt");
FileReader filereader = new FileReader(filename);


Both ways give me the AccessControlException ................

How do you guys usually read in file (other than passing it the file name... I'm not reading in from the main(), rather I'm reading the file from a panel of my applet).... or can you only read in a file from the main()??

Thanks a lot!!!!
 

manly

Lifer
Jan 25, 2000
13,349
4,105
136
Unsigned applets are sandboxed. (I'm pretty sure) they cannot access the local filesystem, even read-only. Similarly, they cannot open socket connections to anywhere except the originating host web server.

The Java2 security model does allow opening up the sandbox; I believe you'll need to investigate applet signing and some other security APIs.
 

spp

Golden Member
Jul 9, 2001
1,513
0
76
well, I got the same problem while using the geImage method in the applet, but I resolved that using the getCodeBase() thing.

so does that mean I cannot read in any file from an applet? I do know that I will be putting this applet on the server, but I'm just developing it on my own computer... so would it work if I just put it on the server?

Thanks!!