package com.jp.copy; import java.io.BufferedInputStream; import java.io.BufferedOutputStream; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.util.Date; public class Copy { public static void copy(String file,String toPath){ BufferedInputStream bis=null; BufferedOutputStream bos=null; byte[] bt=new byte[1024*1024]; try { bis=new BufferedInputStream(new FileInputStream(file)); bos=new BufferedOutputStream(new FileOutputStream(toPath)); int b=0; while((b=bis.read(bt))!=-1){ bos.write(bt, 0, b); } } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); }finally{ if(bis!=null){ try { bis.close(); } catch (IOException e) { e.printStackTrace(); } } if(bos!=null){ try { bos.close(); } catch (IOException e) { e.printStackTrace(); } } } } public static void main(String[] args) { System.out.println(new Date()); copy("d:/电影/你丫闭嘴东北话版CD2.rmvb","c:/你丫闭嘴东北话版CD2.rmvb"); System.out.println(new Date()); } }