java合并MP3

来源:互联网 发布:windows 能安装wdcp吗 编辑:程序博客网 时间:2024/05/06 22:58
[java] view plaincopyprint?
  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 0
原创粉丝点击