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{
   //create file input stream object and file output stream object
    FileInputStream fis = new FileInputStream (sfilename);
    FileOutputStream fos = new FileOutputStream (dfilename);
   
     
    //Looping the contents of a file and writing it out to an external file
     int read = Fis.read ();//Read a byte from the associated source file, or 1 if the end of the file is reached.
     while (read! =-1) {
      fos.write (read);// Writes out a byte to its associated target file
      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.printstacktrace ();
}
T2 = System.currenttimemillis ();
System.out.println ("spents" + (T1-T2));
}

}

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.