[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

How to save a File using File Chooser in Netbeans

Posted on 2009-04-25
7
Medium Priority
?
606 Views
Last Modified: 2013-12-14
I can save a file generally, but I want to save that file at the directory of choice by the user. Has anybody got any easy steps in doing this I have been confused with some tutorials.
0
Comment
Question by:namsu55
  • 5
  • 2
7 Comments
 
LVL 86

Expert Comment

by:CEHJ
ID: 24231417
File f = new File(fc.getFile());
// Write to that file
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 24231421
Sorry

File f = new File(fc.getSelectedFile());
// Write to that file
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 24231430
Sorry - not woken up yet. Only

File f = fc.getFile();

is necessary. If you are choosing directories only, you *can* do

File f = new File(fc.getSelectedFile(), "x.txt");

then you can write to x.txt in the directory of the user's choice
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Comment

by:namsu55
ID: 24231449
Just having a try.
0
 

Author Comment

by:namsu55
ID: 24231539
Hi CEHJ, What happens is, the File Chooser loads, and I end up having to select a file to save a file. Is it possible to have a file already loaded in the save dialog, for the user to save where they prefer.

Example: File selected from c:\programs and user saves it to desktop (file already selected)
0
 
LVL 86

Accepted Solution

by:
CEHJ earned 1500 total points
ID: 24231591
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 24338420
:-)
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
Suggested Courses
Course of the Month19 days, 11 hours left to enroll

872 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question