5 Replies Latest reply: Apr 22, 2010 7:33 AM by 800387 RSS

    java.io.IOException: Access Denied

    843810
      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