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?
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.
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?
Please copy and paste here the full text of the error message.
C:\Users\James\Documents (Access is denied)
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?
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)
Does that path exist?java.io.FileNotFoundException: C:\Users\James\Documents (Access is denied)
What code is at line 340 in the Carpet.java file?at Carpet.saveDataA(Carpet.java:340)
byrdman (August 2nd, 2011)
the path exists
line 340:
PrintWriter roomfile = new PrintWriter(out);
What is the value of the out variable? Is it a file or a directory?