Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 8 of 8

Thread: JFileChooser save dialog box "access is denied" error

  1. #1
    Junior Member
    Join Date
    Aug 2011
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default JFileChooser save dialog box "access is denied" error

    JFileChooser saver = new JFileChooser();
    saver.setFileSelectionMode(JFileChooser.DIRECTORIE S_ONLY);
    if(saver.showSaveDialog(null) == JFileChooser.APPROVE_OPTION)
    {
    out = saver.getSelectedFile();
    }


    anyone know what i'm doing wrong?


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    22,310
    Thanks
    56
    Thanked 2,373 Times in 2,344 Posts

    Default Re: JFileChooser save dialog box "access is denied" error

    Please copy and paste here the full text of the error message.

  3. #3
    Junior Member
    Join Date
    Aug 2011
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: JFileChooser save dialog box "access is denied" error

    C:\Users\James\Documents (Access is denied)

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    22,310
    Thanks
    56
    Thanked 2,373 Times in 2,344 Posts

    Default Re: JFileChooser save dialog box "access is denied" error

    Please post ALL of the error message, not just one line.
    Did you get a stack trace that shows what methods are being called from what source lines in what programs?

  5. #5
    Junior Member
    Join Date
    Aug 2011
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: JFileChooser save dialog box "access is denied" error

    like this?

    java.io.FileNotFoundException: C:\Users\James\Documents (Access is denied)
    at java.io.FileOutputStream.open(Native Method)
    at java.io.FileOutputStream.<init>(FileOutputStream.j ava:179)
    at java.io.FileOutputStream.<init>(FileOutputStream.j ava:131)
    at java.io.PrintWriter.<init>(PrintWriter.java:218)
    at Carpet.saveDataA(Carpet.java:340)
    at Carpet.actionPerformed(Carpet.java:188)
    at javax.swing.AbstractButton.fireActionPerformed(Abs tractButton.java:1995)
    at javax.swing.AbstractButton$Handler.actionPerformed (AbstractButton.java:2318)
    at javax.swing.DefaultButtonModel.fireActionPerformed (DefaultButtonModel.java:387)
    at javax.swing.DefaultButtonModel.setPressed(DefaultB uttonModel.java:242)
    at javax.swing.plaf.basic.BasicButtonListener.mouseRe leased(BasicButtonListener.java:236)
    at java.awt.AWTEventMulticaster.mouseReleased(AWTEven tMulticaster.java:272)
    at java.awt.Component.processMouseEvent(Component.jav a:6267)
    at javax.swing.JComponent.processMouseEvent(JComponen t.java:3267)
    at java.awt.Component.processEvent(Component.java:603 2)
    at java.awt.Container.processEvent(Container.java:204 1)
    at java.awt.Component.dispatchEventImpl(Component.jav a:4630)
    at java.awt.Container.dispatchEventImpl(Container.jav a:2099)
    at java.awt.Component.dispatchEvent(Component.java:44 60)
    at java.awt.LightweightDispatcher.retargetMouseEvent( Container.java:4577)
    at java.awt.LightweightDispatcher.processMouseEvent(C ontainer.java:4238)
    at java.awt.LightweightDispatcher.dispatchEvent(Conta iner.java:4168)
    at java.awt.Container.dispatchEventImpl(Container.jav a:2085)
    at java.awt.Window.dispatchEventImpl(Window.java:2478 )
    at java.awt.Component.dispatchEvent(Component.java:44 60)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java: 599)
    at java.awt.EventDispatchThread.pumpOneEventForFilter s(EventDispatchThread.java:269)
    at java.awt.EventDispatchThread.pumpEventsForFilter(E ventDispatchThread.java:184)
    at java.awt.EventDispatchThread.pumpEventsForHierarch y(EventDispatchThread.java:174)
    at java.awt.EventDispatchThread.pumpEvents(EventDispa tchThread.java:169)
    at java.awt.EventDispatchThread.pumpEvents(EventDispa tchThread.java:161)
    at java.awt.EventDispatchThread.run(EventDispatchThre ad.java:122)

  6. #6
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    22,310
    Thanks
    56
    Thanked 2,373 Times in 2,344 Posts

    Default Re: JFileChooser save dialog box "access is denied" error

    java.io.FileNotFoundException: C:\Users\James\Documents (Access is denied)
    Does that path exist?

    at Carpet.saveDataA(Carpet.java:340)
    What code is at line 340 in the Carpet.java file?

  7. The Following User Says Thank You to Norm For This Useful Post:

    byrdman (August 2nd, 2011)

  8. #7
    Junior Member
    Join Date
    Aug 2011
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: JFileChooser save dialog box "access is denied" error

    the path exists

    line 340:
    PrintWriter roomfile = new PrintWriter(out);

  9. #8
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    22,310
    Thanks
    56
    Thanked 2,373 Times in 2,344 Posts

    Default Re: JFileChooser save dialog box "access is denied" error

    What is the value of the out variable? Is it a file or a directory?

Similar Threads

  1. Replies: 7
    Last Post: August 13th, 2011, 02:22 AM
  2. Replies: 6
    Last Post: November 12th, 2010, 04:40 AM
  3. Replies: 6
    Last Post: August 18th, 2010, 06:41 PM
  4. Replies: 1
    Last Post: March 31st, 2010, 10:42 PM
  5. "java.lang.NoSuchMethodError: main" and "fatal exception occured."
    By joachim89 in forum What's Wrong With My Code?
    Replies: 2
    Last Post: January 10th, 2010, 08:35 AM