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("写文件关闭失败");
}
/**
* @param args
* @throws IOException
*/
public static void main(String[] args) throws IOException {
long start = System.currentTimeMillis();
copy_4();
long end = System.currentTimeMillis();
System.out.println((end-start)+"毫秒");
}
private static void copy_4() throws IOException {
FileInputStream fis = new FileInputStream("c:\\0.mp3");
FileOutputStream fos = new FileOutputStream("c:\\4.mp3");
int ch = 0;
while((ch=fis.read())!=-1){
fos.write(ch);
}
fos.close();
fis.close();
}
private static void copy_3() throws IOException {
FileInputStream fis = new FileInputStream("c:\\0.mp3");
FileOutputStream fos = new FileOutputStream("c:\\3.mp3");
BufferedInputStream bufis = new BufferedInputStream(fis);
BufferedOutputStream bufos = new BufferedOutputStream(fos);