How to merge two mp3 files into one (combine/join)

前端 未结 2 446
死守一世寂寞
死守一世寂寞 2020-11-30 07:07

Can any tell how to combine/merge two media files into one ?

i found a topics about audioInputStream but now it\'s not supported in and

2条回答
  •  一整个雨季
    2020-11-30 07:44

    import java.io.*;
    public class TwoFiles
    {
        public static void main(String args[]) throws IOException
        {
            FileInputStream fistream1 = new FileInputStream("C:\\Temp\\1.mp3");  // first source file
            FileInputStream fistream2 = new FileInputStream("C:\\Temp\\2.mp3");//second source file
            SequenceInputStream sistream = new SequenceInputStream(fistream1, fistream2);
            FileOutputStream fostream = new FileOutputStream("C:\\Temp\\final.mp3");//destinationfile
    
            int temp;
    
            while( ( temp = sistream.read() ) != -1)
            {
                // System.out.print( (char) temp ); // to print at DOS prompt
                fostream.write(temp);   // to write to file
            }
            fostream.close();
            sistream.close();
            fistream1.close();
            fistream2.close();
        }
    }
    

提交回复
热议问题