• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

file deleting problem

 
Ranch Hand
Posts: 115
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Bartender
Posts: 4121
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
yep.. go here for more info
http://java.sun.com/docs/books/tutorial/security1.2/
reply
    Bookmark Topic Watch Topic
  • New Topic