Skip to Main Content

Java APIs

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

java.io.IOException: Access Denied

843810Apr 18 2010 — edited Apr 22 2010
Hello there, I'm switching from Microsoft's C# to Sun's Java. I'm still learning but I'm getting an exception saying java.io.IOException: Access Denied. The program runs fine in NetBeans console, but when I run it from a Jar file, it gives me that exception. Here's the code where it occurs.

File file = new File(filename);
boolean success = file.createNewFile();
if (success)
{
}
else
{
BufferedReader overwriteprompt = new BufferedReader(new InputStreamReader(System.in));
System.out.println("The file already exists! Do you want to overwrite it?");
String overwriteyn = overwriteprompt.readLine();
if (overwriteyn.contains("y") || overwriteyn.contains("Y"))
{
file.delete();
file.createNewFile();
}
else
{
Main.ShowMainMenu(true);
}
}
Please help! Thanks
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 20 2010
Added on Apr 18 2010
5 comments
3,728 views