FilePermission
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Sanjay_Mistry
Posted On:   Thursday, May 2, 2002 12:56 PM

I am using tomcat 4.0.3 to run my application. In my application, I am storing some file in certain directory. I need to delete these files if it grows older then 5 days or it grows more thrn 5MB. In my application, I am setting new FilePermission(path, "read") to set the permission of this file. Everytime, I decide to delete the file, I do following SecurityManager sm = System.getSecurityManager(); try{ sm.checkDelete(path); new File(path).delete(); }catch(SecurityException se) System.out.println("you are not allowed to delte the file"); } this is expected behaviour. But after then when file    More>>

I am using tomcat 4.0.3 to run my application. In my application, I am storing some file in certain directory. I need to delete these files if it grows older then 5 days or it grows more thrn 5MB.



In my application, I am setting

new FilePermission(path, "read") to set the permission of this file. Everytime, I decide to delete the file, I do following


SecurityManager sm = System.getSecurityManager();

try{

sm.checkDelete(path);

new File(path).delete();

}catch(SecurityException se)

System.out.println("you are not allowed to delte the file");

}



this is expected behaviour. But after then when file meets my criteria to be deleted, I am doing following:


new FilePermission(path, "delete");



so, now the file must be able to be deleted when I trying to checkDelete() and trying to delete.



It seems like new file permission are not being set to the same file again.


Any clue any one ?


Thanks.

   <<Less

Re: FilePermission

Posted By:   Zac_Jacobson  
Posted On:   Thursday, May 9, 2002 09:49 AM

Try:

new FilePermission( path, "read,delete" );
instead of the two calls.

Chears,
Zac

About | Sitemap | Contact