java合并MP3

[java]  view plain copy print ?
  1. File file1 = new File("C:\\mp3\\2.mp3");  
  2.         File file2 = new File("C:\\mp3\\3.mp3");   
  3.           
  4.         InputStream is1 = new FileInputStream(file1) ;   
  5.         InputStream is2 = new FileInputStream(file2) ;  
  6.           
  7.         OutputStream os = new FileOutputStream("c:/a.mp3") ;  
  8.           
  9.         byte[]b1=new byte[128];  
  10.         byte[]b2=new byte128 ];  
  11.         int len1 =0;  
  12.         int len2 =0;  
  13.         int index = 0;  
  14.           
  15.         while((len1 = is1.read(b1))!=-1){  
  16.             index++;  
  17.             if(index==1){  
  18.                 continue ;   
  19.             }  
  20.             os.write(b1, 0, len1 ) ;   
  21.         }  
  22.         index=0;  
  23.         while((len2 = is2.read(b2))!=-1){  
  24.             index++ ;  
  25.             os.write(b2, 0, len2 ) ;  
  26.         }  
  27.           
  28.         is1.close() ;  
  29.         is2.close() ;  
  30.         os.flush();  
  31.         os.close() ;  

合并时候两个MP3的格式必须是一样的,如果不是一样的第二个MP3将会无法正常播放。 
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值