首先这是写死的代码 ... 生成的mp3文件是可以播放的
File file = new File(dir + "cing2.wav");
File file2 = new File(dir + "a.wav");
execute(file, "f://111.mp3");
execute(file2, "f://222.mp3");
File file3 = new File("f://111.mp3");
File file4 = new File("f://222.mp3");
InputStream is1 = new FileInputStream(file3) ;
InputStream is2 = new FileInputStream(file4) ;
OutputStream os = new FileOutputStream("f:/1.mp3") ;
byte[]b1=new byte[128];
byte[]b2=new byte[128];
int len1 =0;
int len2 =0;
int index = 0;
while((len1 = is1.read(b1))!=-1){
index++;
if(index==1){
continue ;
}
os.write(b1, 0, len1 ) ;
}
index=0;
while((len2 = is2.read(b2))!=-1){
index++ ;
os.write(b2, 0, len2 ) ;
}
is1.close();
is2.close();
os.flush();
os.close() ;
这里是我把他写成 动态循环的代码
OutputStream os = new FileOutputStream("f://k.mp3") ;
byte[]b1=new byte[128];
int len1 =0;
int index = 0;
for(int i = 0; i
System.out.println(listArr.get(i));
execute(new File(dir + listArr.get(i)), "f://"+i+".mp3");
InputStream is = new FileInputStream(new File(dir + listArr.get(i)));
while((len1 = is.read(b1))!=-1){
index++;
if(index==1){
continue ;
}
os.write(b1, 0, len1 ) ;
}
}
生成合并的mp3 却整整大了几倍,而且不能播放,是什么原因呢