troubleshooting Question

using java JFileChooser Action performed to put file in specific folder

Avatar of blossompark
blossomparkFlag for Ireland asked on
JavaEditors IDEs
10 Comments2 Solutions921 ViewsLast Modified:
Hi,
 the attached application uses JFileChooser to open a file. That is working fine.
What I want  to happen when  "open" is  selected for  the file is  that  the file is put into a specific folder ie C:\\ANT\\Source\\
I have been trying to implement this using the jMenuItemActionPerformed method ( see code snippet below) but end up getting compiler errors.
The current implementation gets no compiler errors,
Can you help put   the chosen file in  the specified folder?
thanks
ps in  the attached file  the method starts at line 107
private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {                                           
JFileChooser jfc = new JFileChooser();
        if(jfc.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) {
            //code to handle choosed file here.
                   // TODO add your handling code here:
                   File file = jfc.getSelectedFile();
                   FileInputStream in = null;
        FileOutputStream out = null;
        File folder = new File("C:\\ANT\\Source\\");
        
    File[] listOfFiles = folder.listFiles();
                   try {
                  
                   in = new FileInputStream(file);
                   
                   }
                   catch(FileNotFoundException e){}
                                   
    }
    }
JFrame.txt
ASKER CERTIFIED SOLUTION
anilallewar

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 2 Answers and 10 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 10 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros