Copy and past files from one place to another

HI i am trying to back up few files from java program plz some one help me out. i am new to programming field.
can i have a sample code so i can do my work easyli
thanx yokivo.

run this code and see:
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
import java.io.*;
public class CopyPasteFiles extends JFileChooser {
boolean directoryOnly = false;
public CopyPasteFiles(String who) {
if (who == "directoryOnly")
directoryOnly = true;
else
directoryOnly = false;
try {
jbInit();
catch(Exception e) {
e.printStackTrace();
private void jbInit() throws Exception {
this.setBounds(new Rectangle(8, 8, 583, 482));
this.setDialogTitle("Select a file");
if (directoryOnly == false) {
this.setFileSelectionMode(JFileChooser.FILES_ONLY);
this.setApproveButtonText("Backup it!");
else {
this.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
this.setApproveButtonText("Select it!");
public boolean implementBackup(File origin, File destination) {
boolean backup = false;
if (origin != null && destination != null) {
String path = origin.getPath();
try {
FileInputStream origin1 = new FileInputStream(origin);
File back1 = new File(destination.getPath() + File.separator + path.substring(path.lastIndexOf(File.separator)+1));
back1.createNewFile();
FileOutputStream back2 = new FileOutputStream(back1);
byte[] bytes = new byte[origin1.available()];
origin1.read(bytes);
back2.write(bytes);
origin1.close();
back2.close();
back1 = null;
catch (Exception err) {
System.out.println("File Error: " + err.getMessage());
backup = true;
return backup;
public static void main(String[] args) {
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
catch(Exception err) {
System.out.println("General Error: " + err.getMessage());
err.printStackTrace();
CopyPasteFiles copyPasteFiles1 = new CopyPasteFiles("fileOnly");
int returnValue1 = copyPasteFiles1.showOpenDialog(copyPasteFiles1);
File directorySelected = null;
File fileSelected = null;
if (returnValue1 == JFileChooser.APPROVE_OPTION) {
fileSelected = copyPasteFiles1.getSelectedFile();
boolean isDirectory = false;
while (isDirectory == false) {
CopyPasteFiles copyPasteFiles2 = new CopyPasteFiles("directoryOnly");
int returnValue2 = copyPasteFiles2.showOpenDialog(copyPasteFiles2);
if (returnValue2 == JFileChooser.APPROVE_OPTION) {
directorySelected = copyPasteFiles2.getSelectedFile();
if (directorySelected.isDirectory())
isDirectory = true;
else
isDirectory = true;
boolean isBackup = copyPasteFiles1.implementBackup(fileSelected, directorySelected);
int messagebox = 0;
if (isBackup == true)
messagebox = JOptionPane.showConfirmDialog(null, "Backup: YES.", "Caution!", JOptionPane.OK_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE);
else
messagebox = JOptionPane.showConfirmDialog(null, "Backup: NO.", "Caution!", JOptionPane.OK_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE);
System.exit(0);

Similar Messages

  • Can I Copy and Paste text from one Contact to Another on iPhone 3G?

    Can I Copy and Paste text from one Contact to Another on iPhone 3G?
    Or even better while the iPhone is connected to my PC can I view the address book on the iPhone and make changes using my PC keyboard?
    I had a challenge importing from my outlook as it created dual entries for people I had with multiple email addresses or telephone numbers so I need to copy and paste contact info from one to antoher.
    Can anyone help?

    MCWEB wrote:
    Can I Copy and Paste text from one Contact to Another on iPhone 3G?
    You will be able to do copy & paste when 3.0 comes out this summer.
    Or even better while the iPhone is connected to my PC can I view the address book on the iPhone and make changes using my PC keyboard?
    No. You would make changes to the address book on your PC and then sync via iTunes.

  • How do I copy and paste pics from one event to another in iPhoto?

    I'm trying to copy and paste in iPhoto, but every time I get to the paste part nothing happens.  The word "paste" even appears on the screen, but it's grayed out. Any suggestions?

    Hi Mel,
    From the picture in your post, it seems that you are using SharePoint 2010 workflow platform.
    If that is the case, I recommend to use Copy List Item action to copy the current item to other lists instead.
    If you still want to use Create List Item action, could you please provide more details about the two steps in your workflow:
    I am not sure why you need to set the workflow variable to get the ID in the Checklist2.
    Best regards.
    Thanks
    Victoria Xia
    TechNet Community Support

  • Can I copy and past iPhoto from one computer to another?

    I just bought a used Mac Mini to give to my in-laws. I used the original boot disks to reinstall the software. I then upgraded to Leopard. When all was said and done, everything was wonderful except that iPhoto was nowhere to be found. Going back to the original install disks in Tiger I tried to install via the 'bundled software' but got a 'failed install' because disk 2 apparently is faulty.
    Can I copy my iPhoto application from my iMac Intel Core 2 to the MacMini? I have tried several other strategies involving install disks, etc. It's iPhoto 6.06. I'm stymied.

    Thanks, Terence. I thought probably that was the case. I guess my only choice is to go back to the beginning with the Tiger install and see if it comes out right.

  • Copy and paste clips from one project to another

    i have made highlight film of my kids playing sports over the months. i would like to make one that had bits and pieces of all the previous. how do i see all the frames like you can in the events section?

    Hi
    NO ! - and when iMovie moved from the 1 to HD6 series (in last versions this worked greatly) - to iMovie'08 or 09 or 11
    This basic and very vital function was lost (among lot's of Important functions)
    There is a cumbersome way around (most probably more than one way to do it - this is mine)
    • Duplicate the project with needed clips (ctrl-click on its title in Project Library list)
    • In Copy - Delete what You don't need
    • Share it as a full Quality QuickTime .mov
    • Import this into Your New Project
    Cons: Effects and texts and so on can not be further edited as the clip-movie is flatted to one piece - If You need to do this I suggest You to re-build from scratch.
    Yours Bengt W

  • I'm not able to copy and paste files from my mac to hard disk and usb. I have tried dragging the items to those devices but it won't work. I also have tried copying and pasting those files onto those devices but that doesn't work too. Can any one help?

    I'm not able to copy and paste files from my mac to hard disk and usb. I have tried dragging the items I want to copy to those devices but it won't work. I also have tried copying and pasting those files onto those devices too but that doesn't work too. Can any one help?

    Hi BobRz
    Thanks for you suggestion but it didn't work - are there other ways for solving this problem? Or is it because my files that I want to copy and paste onto my hard disk etc are too big? (However there is space on my hard disk and it works on a PC)

  • How do I copy and paste files from a windows remote server to my mac?

    How can i copy and paste files from a remote server (windows) to my mac? i have installed cord to connect to the server but now i can´t cpy the files to my mac!

    Hi Sara.  Tanks for responding.  If I cannot figure this out (I  was up
    until 2am last night), I want to cancel my subscription.
    Here are two files you can check on/help me with.  When I try again,  it
    comes up 'an error has occurred when trying to access the service.'
    Please advise.
    Pat Tomassi
    In a message dated 11/1/2014 12:55:23 A.M. Eastern Daylight Time, 
    [email protected] writes:
    How  do I copy and paste text from a converted Word document?
    created by Sara.Forsberg (https://forums.adobe.com/people/Sara.Forsberg) 
    in Adobe Acrobat.com Services - View the full  discussion
    (https://forums.adobe.com/message/6888908#6888908)

  • I am having problems copying and pasting clips from one project timeline to another. When I do this they often alter in length. Sometimes by two frames. Other times they lose a chunk off the end of the last clip in the sequence. Has anyone else found

    I am having problems copying and pasting clips from one project timeline to another. When I do this they often alter in length. Sometimes by two frames. Other times they lose a chunk off the end of the last clip in the sequence. Has anyone else found this?

    You need to give a lot more information about the media specifications and the project properties you're using in the different projects.

  • How to copy and paste text from one photo book page to another.

    hello,i downloaded this software 2days ago,and i've been having so much fun with it. pls i need help on how to copy and paste text from one photo book page to another. Secondly how to copy my completed photo book pages project to another laptop for printing. thanks
    This question was solved.
    View Solution.

    Hi DG.
    The easiest way to copy an HP Photo Creations project to another computer is to click the Share button. That will upload the project to the Web and give you a link you can paste into an email. Clicking the link on the other computer allows you to download the project and personalize it. This quick video shows the process. (The screen looks slightly different now, but the concept is the same.)
    Another way to share a project is copy the project folder to a thumb drive. Look in Documents/HP Photo Creations/My Things to find your saved projects.
    Our customer support team would be happy to walk you through the process. Contact them at [email protected]
    Hope this helps,
    RocketLife 
    RocketLife, developer of HP Photo Creations
    » Visit the HP Photo Creations Facebook page — news, tips, and inspiration
    » See the HP Photo Creations video tours — cool tips in under 2 minutes
    » Contact Customer Support — get answers from the experts

  • Why is it no longer Possible to Copy and Paste files from Illustrator CC to Fireworks?

    Why is it no longer Possible to Copy and Paste files from Illustrator CC to Fireworks?

    What do "normal" AI prefs mean? AICB or PDF compliant? You might wanna try to turn off the latter....
    Mylenium

  • Copy and paste files from Windows Explorer

    Hi everybody,
    For a part of my application I need to copy and paste files and folders from Windows explorer to the vi shown in the picture.
    Does anybody know how to implement this with the clipboard functionality.
    Also drag and drop would be very nice (but thats maybe a later step...)
    Best regards, Helmut

    Hello Friedr,
    drag and drop is the easy part!
    Use a path control, this will naturally allow drag and drop. If a file is dropped on this a 'Value Change' event is fired! with this event you can load the data into the picture. To get a nice drag and drop functionality you should make the path transparent and resize to the size of the picture control. This will work fluently!
    To use the clipboard, LV 8 has an functionality for this, I think it is an application event.
    Success Ton
    PS I didn't see you image maybe it was removed when you did a preview these have the bad habit of removing the attachments!
    Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
    Nederlandse LabVIEW user groep www.lvug.nl
    My LabVIEW Ideas
    LabVIEW, programming like it should be!

  • Cutting and pasting tables from one project to another

    When cutting and pasting existing tables from one project to
    another, the line weights for the cell borders seem to vary at
    random - some are the original line weight and some are heavier
    when pasted.
    I've tried sorting things out with the table properties
    dialogue, but to no effect.
    Is there a quick fix, or am I better importing in whole
    topics and then editing the imported topic?

    Hi Colum/Peter,
    It's not a custom table, I just need to copy an existing
    table from one project to another.
    My blasted developers (may the fleas of a thousand camels,
    etc), just decided to change the toolbars in one of our
    applications. As this toolbar appears in slightly different guises
    in about 6 tabs, I was trying to update the table that shows what
    icon does what and cut and paste that table into all the sub
    projects I have. Each table then only needs a minor edit for a few
    icons specific to that sub-project.
    Peter's on the right track. When I cut and pasted the table
    it also pasted in a number of lines of HTML associated with the
    styles in the other project. If I delete those lines, the table
    then appears as it should.
    Thanks for prompt response

  • Best way to copy large VM files from one drive to another?

    Hi all, I am wondering what the best and fastest way there is to copy a large VM file from one drive to another (external drive to internal drive). Should the .pvm folder (in my case with Parallels) be zipped first? The files I need to copy range from 50 to 70gb. thx for any insight! ps. Even Bombich admits it's difficult for CCC to do...not clear why, but it does slow a full clone down to a crawl. I also have Chronosync at my disposal, but suspect the same is true there as well. Cheers!
    coocoo

    I don't think it matters much which way you do the job. I use Parallels to compress by drives on a regular basis. If you want to copy a dynamic VM, which can grow to just about any size as required, to another drive you will use about the same amount of time zipping the VM - transfering the VM - unzipping the VM, as you would just moving the VM.
    I've moved my VM files to a second partition that does not get cloned to my bootable backup that I create with SuperDuper. I've excluded my entire VM folder from Time Machine and just make zipped backups for each system after any large Service Pack Updates from Microsoft, or any intricate program installations. These get copied to a second partition on my Time Machine drive manually.
    My VM's sizes are kept under control by using common Documents-Movies-Music folders for the Mac and the VM's. My VM's do not have the data files the programs use, they are on my Mac and get backed up every hour with Time Machine.
    Reinstalling a VM just means deleting the broken copy, unzipping my latest backup, and putting into the same folder that Parallels knows to use. The data files are always accessible, even if they were created after my latest VM backup.

  • I able to copy and paste files from external hard drive to mac, but not the other way around. Please suggest. Thanks

    I m able to copy and paste selected files from external hard drive to my mac but not the other way around. Im not able to copy files from Mac to external hard drive.
    The same is working fine with USB flash memory.
    Please help.

    Vijay Raymond Daniel wrote:
    The only thing is we need to buy this software. if there is a free solution to inter change files between NTFS and HFS it would be better,
    Don't use NTFS, remove your data off it first and change the format to something the Mac and PC can read, but doens't cost money or require software.
    Drives, partitions, formatting w/Mac's + PC's

  • Copy and Paste Formula from One Cell to Multiple (How?)

    I am aware of the "autofill" function by dragging the bottom-right corner of a cell containing a formula.
    However, I cannot possibly do this if I want to copy the formula and paste it into 10,000 cells.
    If I specify a range of cells to paste the copied formula - only the first cell gets it. I have seen this problem in previous iWork for a long time but am surprised Apple has not improved it (or made it obvious enough for me to get it at first sight).
    Thanks!

    Hello
    It's really boring to read several times the same comments: +When I use Autofill on formulae to copy them into empty rows I end up with little red triangles saying it isn't a valid formula. In Excel and Lotus 123 I can just use Ctrl-C and Ctrl-V to copy and paste into as many cells as I want, why not Numbers?+
    Here we are not Apple employees so you are loosing your time and also the time of all of us reading your posts.
    Of course we may let them unread. But as old helpers, we always assume that when someone post something, it's to ask a question to which one of us may give a answer.
    Your flames are perfectly useless.
    If you wish that Apple take care of your opinion, go to "Provide Numbers Feedback" in the "Numbers" menu and describe your wishes.
    Happily, one poster make me laugh when he wrote that "this anomaly is a long time one in iWork".
    I really don't understand how an application which is in version 1.0 or 1.0.1 may contain a "long time" anomaly !!!!
    And the only responce I may give to all of you is: *if you can't live with this feature, stay with E…l.*
    *We will not miss you !!*
    Yvan KOENIG (from FRANCE samedi 20 octobre 2007 19:47:45)

Maybe you are looking for

  • How can I run a custom program ASYNCHRONOUSLY when booting WinPE?

    I have a custom application that I want to have running during WinPE for my Litetouch deployments. I had this working in SCCM and now I want to get it working in MDT. I have the Netcheck.exe application in my Extras folder, it ends up on the root of

  • Gray progress bar on boot twice now

    I've experienced a gray bar on boot twice now. I upgraded to a 2011 MBP and transferred my 500 GB Toshiba SSD from last year's MBP into the new model, into the SuperDrive slot using a MCE OptiBay (I put the existing SSD into the OptiBay since the Sup

  • Interface on Business System not found

    Hi, I have the following scenario: RFC --> XI --> Webservcie I import the RFC interface and use it directly as interface. At the development system it work's fine productively it doesn't work. Has anybody a hint for me? PS: I compared all. Regards Jo

  • New iMac but iTunes shuts down when I download or add "purchased" videos.

    I just bought a new iMac, first I went to an Apple store and inquired that my main use would be with iTunes. I began to transfer songs from my iPod to the Mac using the Senuti file. The major problem is that I am forced to manually add the songs and

  • Regarding Packing

    hi All, I have a scenario where fg is packed. In case if i have to change the packing material, how do i handle this in SAP Business One? Thanks, Joseph