import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
/*
* 复制.mp3文件
*
* 因为是媒体文件,所以使用字节流
*
* */
public class Mp3Copy {
public static void main(String[] args){
mp3Copy();
}
public static void mp3Copy(){
FileInputStream fis = null;
FileOutputStream fos = null;
try{
fis = new FileInputStream("g:\\关喆 - 征服.mp3");
fos = new FileOutputStream("g:\\关喆 - 征服123.mp3");
//通过缓冲区提高效率。
BufferedInputStream bufis = new BufferedInputStream(fis);
BufferedOutputStream bufos = new BufferedOutputStream(fos);
int by = 0;
while((by=bufis.read())!=-1){
bufos.write(by);
}
}
catch(IOException e){
throw new RuntimeException("复制失败");
}
finally{
if(bufis != null)
try{
bufis.close();
}
catch (IOException e)
{
e.printStackTrace();
}
if(bufos != null)
try{
bufos.close();
}
catch (IOException e)
{
e.printStackTrace();
}
}
}
}
编译时出错 bufos cannot be resolved to a variable
bufos cannot be resolved
at Mp3Copy.mp3Copy(Mp3Copy.java:35)
at Mp3Copy.main(Mp3Copy.java:15)
求大神们解惑啊 |
|