Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

file deleting problem

 
karan, chopra
Ranch Hand
Posts: 115
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi all,
i wrote the following code for deleting 3 txt files from which i read some data in my applet:
public void stop() {

File f1 = new File("h:/FrontPage Webs/Content/gaurav/node.txt");
f1.delete();
File f2 = new File("h:/FrontPage Webs/Content/gaurav/link.txt");
f2.delete();
File f3 = new File("h:/FrontPage Webs/Content/gaurav/incident.txt");
f3.delete();
System.out.println("hi bachha");
}
I also wrote this in the destroy method.but when i run the applet and dispose it then the files are not
deleted and the folloing exception is thrown..please help me...

at java.security.AccessControlContext.checkPermission(AccessControlConte
xt.java:272)
at java.security.AccessController.checkPermission(AccessController.java:
399)
at java.lang.SecurityManager.checkPermission(SecurityManager.java:545)
at java.lang.SecurityManager.checkDelete(SecurityManager.java:1005)
at java.io.File.delete(File.java:709)
at Simple.stop(Simple.java:648)
at sun.applet.AppletPanel.run(AppletPanel.java:377)
at java.lang.Thread.run(Thread.java:484)
java.security.AccessControlException: access denied (java.io.FilePermission h:\F
rontPage Webs\Content\gaurav\node.txt delete)
at java.security.AccessControlContext.checkPermission(AccessControlConte
xt.java:272)
at java.security.AccessController.checkPermission(AccessController.java:
399)
at java.lang.SecurityManager.checkPermission(SecurityManager.java:545)
at java.lang.SecurityManager.checkDelete(SecurityManager.java:1005)
at java.io.File.delete(File.java:709)
at Simple.destroy(Simple.java:661)
at sun.applet.AppletPanel.run(AppletPanel.java:387)
at java.lang.Thread.run(Thread.java:484)
thanks a million in advance
regards
karan
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can't do this in a non-signed applet... If this were possible every h4x0r d00d would have a little applet on his homepage that had lines that tried to delete autoexec.bat, config.sys, win.exe, and other system files...

-Nate
 
Charlie Boss
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yep.. go here for more info
http://java.sun.com/docs/books/tutorial/security1.2/
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic