java怎么在哪写代码_java把这段代码不写死问题出现在哪儿

首先这是写死的代码 ... 生成的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 却整整大了几倍,而且不能播放,是什么原因呢

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值