Java Copy File contents

Source: Internet
Author: User
Tags getmessage

Description

Copy the contents of the a.txt under the D drive to the e-drive under the E.txt file

private static void Copydatabase () {try {file F1 = new File ("D:/a.txt");  File F2 = new file ("E:/e.txt"), inputstream in = new FileInputStream (F1), outputstream out = new FileOutputStream (F2); byte[] BUF = new Byte[1024];int len;while (len = In.read (buf)) > 0) {out.write (buf, 0, Len);} In.close (); Out.close (); System.out.println ("File copied.");} catch (FileNotFoundException ex) {System.out.println (Ex.getmessage () + "in the specified directory."); System.exit (0);} catch (IOException e) {System.out.println (E.getmessage ());}}


Java Copy File contents

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.