刚才用读写字符流写了一个程序,把e盘的MP3复制到d盘,复制过去了但是不能播放,这是怎么回事?代码如下
package execisetest;
import java.io.*;
public class FileCopy {
public static void main(String[] args)
{
copyfile();
}
public static void copyfile()
{
FileWriter fw=null;
FileReader fr=null;
try{
fw=new FileWriter("d:\\dd.mp3");
fr=new FileReader("e:\\dd.mp3");
char [] buf=new char[1024];
int num=0;
while((num=fr.read(buf))!=-1)
{
System.out.println(1);
fw.write(new String(buf,0,num));
}
}catch(IOException e){
System.out.println(e.toString());
}
finally {
try{
fr.close();
fw.close();
}
catch(IOException e){
System.out.println(e.toString());
}
}
}
}
|