Java Efficient File Replication

Source: Internet
Author: User

1File Sourfile =NewFile (start); Source file2File Tarfile =NewFile (end);4                 if(!tarfile.exists ()) {5 tarfile.mkdirs ();6                 }Ten                 if(!sourfile.exists ()) { OneSystem.out.println ("Jump out of this loop" +start); A                     Continue; -                 } -FileInputStream FIS =NULL; -FileOutputStream fos =NULL; +FileChannel in =NULL; -FileChannel out =NULL; A                 Try { at                      -                       -FIS =NewFileInputStream (NewFile (start)); -FOS =NewFileOutputStream (NewFile (end+imagess)); -                      inin =Fis.getchannel (); -out =Fos.getchannel (); toSmallout =Smallfos.getchannel (); +                      -In.transferto (0, In.size (), out); *}Catch(Exception e) { $ e.printstacktrace ();Panax Notoginseng}finally{ - in.close (); + out.close (); the fos.close (); + fis.close (); -}

Java Efficient File Replication

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.