access permission for java.io.file

i had tried this simple code...

but the error occured...

try

{

File myFile = new File("C:\\MyFile.txt");

if (myFile.exists())

{

System.out.println(myFile.getAbsolutePath() +

" already exists.");

}

else

{

if (myFile.createNewFile())

{

System.out.println("Created file " + myFile.getAbsolutePath());

}

else

{

System.out.println("Unable to create file " + myFile.getAbsolutePath());

}

}

}

catch (Exception ex)

{

ex.printStackTrace();

System.out.println(ex.toString());

}

java.security.AccessControlException: access denied (java.io.FilePermission C:\MyFile.txt read)

at java.security.AccessControlContext.checkPermission(Unknown Source)

at java.security.AccessController.checkPermission(Unknown Source)

at java.lang.SecurityManager.checkPermission(Unknown Source)

at java.lang.SecurityManager.checkRead(Unknown Source)

at java.io.File.exists(Unknown Source)

at com.cv.eb.ui.client.ClientDesktop.BasicCompanySetup.ui.testing.<init>(testing.java:30)

at com.cv.eb.ui.client.ClientDesktop.BasicCompanySetup.ui.BasicCompanySetupUI.init(BasicCompanySetupUI.java:52)

at facado.ui.NEFrameCompoletUI.t(Unknown Source)

at facado.ui.NEFrameCompoletUI.setModel(Unknown Source)

at facado.model.NECompoletModel.p(Unknown Source)

at facado.model.NECompoletModel.getCompoletUI(Unknown Source)

at facado.model.NEPanelModel.addNewCompolet(Unknown Source)

at facado.model.NEPanelModel.addNewCompolet(Unknown Source)

at com.cv.eb.ui.navigation.ui.NavigationUI.actionPerformed(NavigationUI.java:108)

at facado.awt.button.NEButton.processActionEvent(Unknown Source)

at facado.awt.button.NEButton.processEvent(Unknown Source)

at java.awt.Component.dispatchEventImpl(Unknown Source)

at java.awt.Component.dispatchEvent(Unknown Source)

at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)

at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)

at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)

at java.awt.Container.dispatchEventImpl(Unknown Source)

at java.awt.Component.dispatchEvent(Unknown Source)

at java.awt.EventQueue.dispatchEvent(Unknown Source)

at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)

at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)

at java.awt.EventDispatchThread.pumpEvents(Unknown Source)

at java.awt.EventDispatchThread.pumpEvents(Unknown Source)

at java.awt.EventDispatchThread.run(Unknown Source)

java.security.AccessControlException: access denied (java.io.FilePermission C:\MyFile.txt read)

Message was edited by:

leileichu

[2880 byte] By [leileichua] at [2007-10-3 3:14:28]
# 1

You have post your topic in forum's category Signed Applets, so i suppose that you know that the error is relative with signed applets and it's caused because you didn't sign the applet. Right?

Then why did you create this topic?

Try sign it and then if your problem exists then post again.....

http://java.sun.com/developer/technicalArticles/Security/Signed/

http://java.sun.com/j2se/1.4.2/docs/guide/plugin/developer_guide/rsa_signing.html

But the next time, spend some time before you ask such obvious things......

JavaPropagatora at 2007-7-14 21:05:41 > top of Java-index,Security,Signed Applets...