import java.io.*;
class CopyMp3
{
public static void main(String[] args)
{
long start = System.currentTimeMillis();
copy();
long end = System.currentTimeMillis();
System.out.println("time="+ (end-start)+"毫秒");
}
public static void copy()
{
BufferedInputStream bis = null;
BufferedOutputStream bos = null;
try
{
bis = new BufferedInputStream(new FileInputStream("F:\\duqing.mp3"));
bos = new BufferedOutputStream(new FileOutputStream("F:\\渡情.mp3"));
byte[] bt = new byte[1024];
int buf = 0;
while((buf = bis.read(bt))!= -1)
{
bos.write(bt, 0, buf);
}
}
catch (IOException e)
{
throw new RuntimeException("复制失败!");
}
finally
{
try
{
if(bis!=null)
bis.close();
}
catch (IOException e)
{
throw new RuntimeException("读文件关闭失败");
}
try
{
if(bos!=null)
bos.close();
}
catch (IOException e)
{
throw new RuntimeException("写文件关闭失败");
}