public static void main(String[] args) throws IOException
{
// TODO 自动生成的方法存根
FileInputStream fis = new FileInputStream(new File("C:\\0.mkv"));
FileOutputStream fos = new FileOutputStream(new File("C:\\2.mkv"));
int len=0;
byte[] by = new byte[1024];
while((len=fis.read(by))!=0)
{
fos.write(by, 0, len);
}
fos.close();
fis.close();
}
}
正常运行,实现了MP3文件复制。
可是,却报了异常。
Exception in thread "main" java.lang.IndexOutOfBoundsException
at java.io.FileOutputStream.writeBytes(Native Method)
at java.io.FileOutputStream.write(Unknown Source)
at MP3CopyDemo.main(MP3CopyDemo.java:32)