How to save a copy of a file to different location using jfilechooser

hi, this is ravikiran,
In my project there is a situation where when a user clicks on some button, a copy of a file(which is initially in my project folder) must be saved to a location specified by the user.
I have no idea how to do this using JFileChooser.
help me,
thanx in advance

JFileChooser lets you choose a file. Once it's done you will have to program the copy function with womething like :
     public void copyToDir(String fileSource,String fileDest) {
          try {
               FileChannel srcChannel = new FileInputStream(fileSource).getChannel();
               FileChannel dstChannel = new FileOutputStream(fileDest).getChannel();
               dstChannel.transferFrom(srcChannel, 0, srcChannel.size());
               srcChannel.close();
               dstChannel.force(true);
               dstChannel.close();
          } catch (IOException e) {
               e.printStackTrace();
     }

Similar Messages

  • "Could not save a copy because the file is already in use..."

    I have read previous discussions of this issue, but nobody suggested a solution. Sometimes when I use the Save As command to save an open file with the same name as an existing Photoshop file that is not currently open, I get the dreaded message: "Could not save a copy because the file is already in use or was left open."
    When this happens, I have to save my open file using a different filename, then change the name in the Finder after manually deleting the original file with that name. This happened occasionally in Photoshop CS3, and is now happening more frequently in CS4. If no one can offer a solution, can someone please tell me if there is a way to officially submit a bug report? The simple truth is that Photoshop costs way too much for a well-known problem like this one to be hanging around version after version. Adobe really needs to fix this and I'd like to tell them so. Thanks!

    alansky1 wrote:
    Adobe really needs to fix this and I'd like to tell them so.
    I've run into this and I'm convinced it's not Adobe. Whenever I've gotten around the problem it's often something from Apple that got in the way.
    I use a simple workaround when Finder/QuickLook isn't letting go of the file. First use a free utility like TinkerTool or Onyx to turn on the Quit command in the Finder. Whenever the Finder gives you trouble, if closing the Finder window in question doesn't solve it, just do the ol' Command-Q. It's a little faster (and maybe safer?) than force-relaunching the Finder. This usually releases files for me when all else fails; it also often cures the annoying "can't eject the volume because it's in use" messages when you've already quit every program you can find.
    There's the question of why Photoshop and not others; I'm not an engineer but I think the sheer size of Photoshop files is a factor. In one instance I noticed that quicklookd was using a lot of RAM, and QuickLook has been implicated by an earlier post in this thread. It isn't unusual for a Photoshop file to be very large compared to other types of documents. It's possible that when QuickLook hits a large Photoshop file, and it does its normal thing of generating a big preview for it, it could get tied up reading that huge image long enough to block another program. Sometimes it seems like QuickLook just hangs on them. When it happens, you can try looking at Activity Monitor to see if something like QuickLook, Spotlight, or some other program is using an unusual amount of CPU or RAM.
    Apple Mail (at least in 10.5) is another major offender by the way. If you attach a file to Apple Mail it will hang on to it as "open" even after you remove the attachment. Other programs will not be able to write to the file that was attached or formerly attached. Nothing short of quitting Apple Mail will make it let go of the file. You'll notice it when you delete a JPEG, PDF, Word doc (definitely not just Photoshop) attachment because you realize you need to make a change and attach it again. Attempting to export an updated one over the old one is blocked until Apple Mail is quit.
    In my experience I think what Chris says is true.

  • How to upload a file to different location using CS Template

    Hi,I have a Data Entry Template with a "File" field and when I upload a document it uploads in the same directory where the Content Item is created. Is there any way to upload the document to some other directory in the Content Server. Say I have a Html folder and there is a template which has a 'file' field. After Saving the content item the uploaded file gets saved in the same folder (Html) in content server, I would like to upload the document in a different folder called "Docs" and the content item in Html folder.Is it possible? If yes then can you please guide me.Thanks,Yaju

    Hi Rajesh,
    Use below code on your "Upload" Action:
         try
    // Give full path of folder on server where you want to upload the file.
              File file = new File("D:\\usr\\sap\\Images\\"+wdContext.currentContextElement().getResource().getResourceName().toString());
    // D:\usr\sap\Images folder should present on server
              FileOutputStream op = new FileOutputStream(file);
              if(wdContext.currentContextElement().getResource()!=null)
                   text=wdContext.currentContextElement().getResource().read(false);
                        while((temp=text.read())!=-1)
                             op.write(temp);
              op.flush();
              op.close();
         catch(Exception e)
              wdComponentAPI.getMessageManager().reportSuccess("Error while uploading file : "+e.getMessage());
    Thanks
    Sandy

  • How do I save a copy of the file?

    I used to be able to save a copy of the file in Fill & Send processm but now it only allows me to save a blank copy ????

    Hi liang.z,
    Let me know which application or service of Adobe you are using. Also let me know the extact steps (workflow) you are following.
    Regards,
    Ajlan Huda.

  • How to save my emails and adressbook files from an old ibook?

    How to save my emails and adressbook files from an old ibook (bought around 2002) ?
    The screen from the old ibook doesn´t work anymore (logicboard problem I guess).
    I saved everything else with starting it in target modus. That worked fine.
    I want to delete the files after that as well, because I wanna give away the old ibook and don´t want anyone to read my emails!
    Little helpers I have:
    A running MacBook
    External Screen (and cables to connect)
    Fire Wire Cable

    Don't know how helpful this will be but I often copy mail from one computer to another, I drag the mail from the mail window to the other computers drop box, then from the other computer double click it and mail asks me what I want to do with it, of course without a screen you'd need to use back to my mac.
    If you don't have back to my mac running, you could set up a second user account on the newer mac, import everything via target mode as suggested by c above, and then drag the mail to the first user account drop box.

  • How to save video messages to a file on Mac?

    How to save video messages to a file on Mac? Please, help. Thank you.Claire

    Claire, I use a Mac w/ the latest copy of Skype and it IS possible to first play the file and then download it.  Steps are available for it but it involves some technical wizardry that can be above some muggles.   Then I found a post where some some VERY bright person made a small downloaded program for the Mac which once the video message has been played recently, you can run this program and download the file for safe keeping ( ALWAYS BACKUP or store it in the cloud for safety )  Kudos are deserved to user alvarop for this! http://community.skype.com/t5/Mac/Video-Message-Exporter-App/m-p/2351609 It worked for me to download a video message that I recently played back.  Let me know if you need any assistance getting it downloaded you can PM me on here and I'll be happy to help with a screenshare. Best Regards,-Shawn G

  • How to save Android contacts as Excel file on Mac computer?

    I want to manage and edit my contacts on my cell phone, my friend suggested me save them as Excel format! So now i am trying this way, but i can't find the right method to do this! Do you know how to save Android contacts as Excel file on Mac computer?

    If you want to save Android Phone contacts to Excel format, you can have a try the following method:
    Step 1. Connect Your Android Phone to Computer
    After downloading and installing the Coolmuster Android Assistant software on your computer, launch it and you will get the program interface prompts you to connect your phone to the computer. Just use a USB cable to connect your phone to the computer and the program will detect the connected phone automatically. If it is the first time to run this software, you may encounter the following picture and be required to enable USB debugging on your phone at first. If your device can be detected by the program, you can directly skip to the next step.
    Step 2: Go to the Contacts windows
    All your phone data are categorized on the top menu. To transfer Android phone's contacts, you can go to click the "Contacts" icon to enter the Contacts window. Navigate to the left panel and click on the "All Contacts" option, then, all the contacts in your phone will show in list on the right window. Mark the contacts you want to backup on your computer and click the button of "Backup".
    Step 3. Start to export contacts to computer at once
    Once you click on the "Backup" button, there will be a "Path" dialog appears, asking you to choose an output location where you want to save the exported contacts. Specify an output folder and then click the "Ok" button. Then, all your phone contacts will be exported to the output location immediately, with all the email address, company's name, home address, and more contacts info perfectly kept in the output CSV or XLS file.

  • How to save settings in the front panel to different files and retrieve it later?

    How to save the front-panel controllers' settings to different files and retrieve it later?
    What I've archived is the "Save Settings" function, but when trying to "Reload Settings", I can only retrieve the saved data to front-panel indicators, but not the controllers!
    Can anybody give me some advises?
    Thanks in advanced!
    Charles Lu

    Hi
    Just write the retrieved data to a local variable (but make it writable first) or property node of the controls.
    Hope this helps.
    Thomas
    Using LV8.0
    Don't be afraid to rate a good answer...

  • How to save iMovie project as .mov file?

    That's my question!

    Dr.E wrote:
    How to save iMovie project as .mov file?
    That's my question!
    Share/Export with Quicktime
    That's my answer, and Welcome, Dr.E to the  boards ...

  • How to save query result in excel file

    Hi all,
    How to save query result in excel file from sql*plus tool.
    thank you

    Do you really need an Excel file (binary) or a simple CSV?
    If you just need a CSV then search for DUMP_CSV at http://asktom.oracle.com or at this forum
    If you need formatting and/or multiple worksheets then you can use free tools like
    https://xml-spreadsheet.samplecode.oracle.com/ or https://exceldocumenttype.samplecode.oracle.com/
    Regards
    Marcus

  • How to save infopath form in XML file

    How to save InfoPath form in XML file.
    I want every new record in InfoPath form save in XML file and also retrieve these records from XML like databases

    Hi,
    Based on your description, my understanding is that you want to save InfoPath form in XML file.
    I have done a test in my SharePoint, Do the following steps:
    Create an form library and publish an InfoPath form into it, Then when we create new document into the form library, it is by default that InfoPath form is saved in XML file.
    Best Regards,
    Lisa Chen
    Lisa Chen
    TechNet Community Support

  • How to 'save a copy' of a pdf?

    I am trying to change the security of the pdf  in which 'extend features in adobe reader' option is enabled. To change this i have to save a copy of a pdf.
    How to save a copy of a pdf  using acrobat sdk or javascript or batch processing?
    I have tried saveAs method in javascript but it doesnt work.
    Please Advice.

    Im trying to save the document in a location, but it is giving me a "Error 3: Bad parameter".
    Here is my code.
    DURING
              ASFileSysReleasePath(fileSys,pathName);
              ASPathName newPathName = ASFileSysCreatePathName(fileSys, ASAtomFromString("D:\\newPdf.pdf"),NULL,NULL);
              PDDocSave(pdDocForExp, PDSaveFull | PDSaveCopy, newPathName,fileSys, NULL, NULL);
              PDDocClose(pdDocForExp);
    HANDLER
               char  buf[256], errmsg[256];
                sprintf(buf,  "Error %d: %s", ErrGetCode(ERRORCODE),      
                ASGetErrorString( ERRORCODE, errmsg,  sizeof (errmsg) ) );
                AVAlertNote(buf);
    END_HANDLER

  • How to save/load JTextPane to/from file?

    One of the simplest questions re Swing.
    How to save a JTextField onto a file?
    And, how to read back it onto a newed JTextPane?
    Yes, I have searched, searched and searched on the net, in vain.

    Assuming he's wanting to do the reasonable thing, I'm trying to do it too.
    linuxoid, I suspect he (and I) are looking for a way to save the contents. After all, a control that you can't get the information out of is pretty useless.
    Styled text is often just a BLOB to the rest of the app. It is in my case, and it probably is in his.
    I'm having the same trouble he is.
    I want to make a JTextPane, let the user edit it, then get some reasonably portable representation of it's current contents that I can serialize. A string representation of XML sounds dandy. Incomprehensible binary is acceptable. A representation in some markup language that I can insert in some other document and have it act like I'm inserting text in the editor would make me more than happy.
    Ideally, what I, and probably he, are looking for is something like
    JTextPane myPainIsGreat = new JTextPane();
    ... life goes on...the user writes poetry and turns the words tacky colors...
    String thisICanDealWith = myPainIsGreat.getStyledTextRepresentation();
    knowing better I'd settle for
    myPainIsGreat.writeStyled(someWriter)
    sadly, JTextPane's write just returns unstyled text

  • Photoshop CS4 "Could not save as...because file is already in use or was left open"

    I have been using Photoshop for years, and CS4 for about a year now.  I have never had this error message pop up until this week.  It started happening right after I did the Adobe update to 11.0.2.  Everytime I try to save a PSD or JPG file now (which are the only two types of files I work with), I get this message preventing me from being able to save;
    "Could not save as... because file is already in use or was left open."
    I have to attempt to Save as about a dozen times before it will finally save the file.  Any suggestions on what could be wrong and how to remedy it?  Is it the update that caused this problem?

    Turn off Caching of Thumbnails in Hidden thumbs.db Files
    People sometimes report that they cannot manipulate their folders as they want to because Explorer has a thumbs.db file open.  Windows 7 apparently generates these files for compatibility with older software that may expect such files to exist in folders with, for example, photos in them.
    The good news is that (with Windows 7 Professional and above) you can disable this through the Group Policy editor:
    Click the Start orb
    Enter gpedit.msc in the search box and hit Enter.
    Expand User Configuration - Administrative Templates - Windows Components.
    Click on Windows Explorer.
    Right-click the entry "Turn off the caching of thumbnails in hidden thumbs.db files" and choose Edit.
    Enable the setting.
    -Noel

  • How do you save your videos in iMovie to a different location on your computer?

    Since i upgraded to OSX Mavericks imovie keeps switching itself off when trying to export video to DVD.
    Genius Bar told me i need to save my videos first then delete imovie and then download imovie from the app store.
    How do i save my videos in imovie to a different location on my imac so i can then delete imovie????

    Copy the iMovie Library. It should be in YourUserFolder/Movies/iMovie Library. See iMovie (2013): Work with multiple libraries

Maybe you are looking for

  • Acrobat PDF Maker freezes at 90% done when converting from Word

    ...and here's the weird thing. When I cancel, the PDF appears on my desktop, named "Microsoft Word - (filename).doc.pdf'. It was working fine up until a few hours ago, exporting the PDF in a few seconds, to the same file path, and with the same name,

  • AnyConnect and Mobile devices

    Hi, is there a way to limit AnyConnect profile only to mobile devices (Android, ipads, etc)? We have AnyConnect mobile licence enabled but i would like to create an Anyconnect profile to allow only mobile device to use it. I should have other AnyConn

  • Help needed with perl Image::Magick module

    I don't know if this is the right place to post this (it might belong in the Newbie corner instead), but I'll give it a try. I need an Image::Magick Perl module (and a load of other modules, which I have found) for a program I desperately need. Now,

  • Getting error in OSB service

    Hi All, I am facing a peculiar error in OSB. I have an application running in OSB. When I redeployed the application it took more than 10 mins to activate the changes which is not at all expected. Also when I deleted the the application and again dep

  • How do I fix issue with computer not authorized yet when authorized it indicated already authorized?

    How do I fix issue with computer not authorized yet when I go to I-Tunes to authorized it indicated already authorized?