Java fourth time job

Source: Internet
Author: User

Import Java.io.FileInputStream; Import java.io.FileNotFoundException; Import Java.io.FileOutputStream; Import java.io.IOException;

public class copyfile{

public static void Copybytesfile (String sfilename,string dfilename)

   throws IOException{//创建文件输入流对象和文件输出流对象FileInputStream fis = new FileInputStream(sFileName);FileOutputStream fos = new FileOutputStream(dFileName); //循环读取文件的内容,同时写出到外部文件 int read = fis.read();//从关联的源文件读一个字节,如果到达文件末的话,返回值为-1。 while(read != -1){ fos.write(read);//向其关联的目标文件写出一个字节 read = fis.read(); }

Empty cache Close Stream object Fis.close (); Fos.close (); }

public static void Main (string[] args) {//TODO auto-generated method stub Long t1,t2; t1 = System.currenttimemillis ();

try {copyfile.copybytesfile ("A.mp3", "Temp.mp3"),} catch (IOException e) {//TODO auto-generated catch block E.printsta Cktrace (); } t2 = System.currenttimemillis (); System.out.println ("spents" + (T2-T1));}}

Java fourth time job

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.