public class CopyMp3 {
public static void main(String[] args) throws IOException {
long start = System.currentTimeMillis();
copy();
long end = System.currentTimeMillis();
long time = end - start;
//获取拷贝时间
System.out.println(time);
}
public static void copy() throws IOException {
MyBufferedInputStream bis = new MyBufferedInputStream(new FileInputStream("demo.mp3"));
BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream("demo_copy.mp3"));
int by = 0;
while((by=bis.myRead()) != -1) {
bos.write(by);
}
bis.myClose();
bos.close();
}
}
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 4096
at day19.MyBufferedInputStream.myRead(MyBufferedInputStream.java:36)
at day19.CopyMp3.copy_2(CopyMp3.java:42)
at day19.CopyMp3.main(CopyMp3.java:14) 作者: 张飞年 时间: 2012-9-11 15:34 本帖最后由 张飞年 于 2012-9-11 15:41 编辑