import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; public class CopyFile { public static void main(String[] args) { // TODO Auto-generated method stub CopyMp3 cy = new CopyMp3(); cy.copy(); } } class CopyMp3{ public void CopyMp3(){} void copy(){ long starttime = System.currentTimeMillis(); try { FileInputStream fis = new FileInputStream("src/a.mp3"); FileOutputStream fos = new FileOutputStream("src/temp.mp3"); byte[] b = new byte[1024]; int read = fis.read(b); while(read!=-1){ fos.write(b); read = fis.read(b); } fis.close(); fos.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } long endtime = System.currentTimeMillis(); System.out.println("用时:"+(endtime-starttime)+"ms"); } }
原文:http://www.cnblogs.com/Mrsli/p/5369316.html