首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

java合拢MP3

2013-03-04 
java合并MP3File file1 new File(C:\\mp3\\2.mp3)File file2 new File(C:\\mp3\\3.mp3) InputSt

java合并MP3

File file1 = new File("C:\\mp3\\2.mp3");File file2 = new File("C:\\mp3\\3.mp3"); InputStream is1 = new FileInputStream(file1) ; InputStream is2 = new FileInputStream(file2) ;OutputStream os = new FileOutputStream("c:/a.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() ;

合并时候两个MP3的格式必须是一样的,如果不是一样的第二个MP3将会无法正常播放。 



热点排行