haven't written an applet in a long time, but they always used to be able to read files in the same directory. for some reason the one I'm working on can't. So I spent a day reviewing security and fond this statement at http://java.sun.com/j2se/1.4.2/docs/guide/security/spec/security-spec.doc3.html
 
"And finally, note that code always automatically has permission to read files from its same (URL) location, and subdirectories of that location; it does not need explicit permission to do so."
 
ok, it wasn't working when I directly accessed it off my hard disk. Maybe it's the url problem. So I uploaded it along with the files I wanted to read to a web location. still won't read the supporting files. "java.security.AccessControlException: access denied (java.io.FilePermission specneed read)..."
 
did someone change the feature that allowed an applet to read files in its own directory and forget to tell javasoft? or am I misinterpreting this? Or is there some additional gotcha I'm overlooking?
 
here's the method that reads the file:
 
public String list_file(String file) throws IOException
{
File f=new File(file);
String content1;
int size=(int)f.length();
int bytes_read=0;
FileInputStream in=new FileInputStream(f);
byte[] data="" byte[size];
while(bytes_read<size)
bytes_read+=in.read(data,bytes_read,size-bytes_read);
content1=new String(data,0);
in.close();
return content1;
}
 
and here's the call to the method.
 
try{specneed=list_file("specneed");}catch(Exception e){catcherrors.setText(e.toString()+catcherrors.getText());}
catcherrors being a text area to display errors
_______________________________________________
Juglist mailing list
[EMAIL PROTECTED]
http://trijug.org/mailman/listinfo/juglist_trijug.org

Reply via email to