You will need the following:
decode base64 to byte data
combine/concat all the byte data of the files
save to a wav
convert to mp3
For getting the bytes out of base64 you can use any method (java 8 apache etc) - I assume you can do that and I havent done anything on it: Decode Base64 data in Java.
So I assume you can do something like this
byte[] bytes = "Hello, World!".getBytes("UTF-8");
String encoded = Base64.getEncoder().encodeToString(bytes);
byte[] decoded = Base64.getDecoder().decode(encoded);
and you have two files converted to byte arrays b1 and b2.
Then you concat the bytes and save to a wav file. If lame mp3 converter is available to you and you can use it (legal issues possibly) then you can do that. Otherwise use some audio software to convert wav to mp3.
try {
byte[] outData=new byte[b1.length+b2.length+];
for(i=0; i<b1.length; i++) outData[i]=b1[i];
for(i=0; i<b2.length; i++) outData[b1.length+i]=b2[i];
AudioFormat af=audioInputStream.getFormat();
InputStream byteArrayInputStream=new ByteArrayInputStream(outData);
AudioFormat af=new AudioFormat(44100f, 16, 2, true, true);
File fo=new File("out-"+(System.currentTimeMillis()/1000)+".wav");
AudioInputStream audioOutputStream=new AudioInputStream(byteArrayInputStream, af, outData.length/af.getFrameSize());
AudioSystem.write(audioOutputStream, AudioFileFormat.Type.WAVE, fo);
String cmd="\""+"C:/lame"+"\""+
" -h "+fo.getName()+" "+fo.getName().substring(0, fo.getName().lastIndexOf(".")+1)+"mp3";
Runtime rt = Runtime.getRuntime();
final Process pr=rt.exec(cmd);
Thread th=new Thread() {
public void run() {
try {
InputStreamReader isr = new InputStreamReader(pr.getErrorStream());
BufferedReader br = new BufferedReader(isr);
String line=null;
int i=0;
while ( (line = br.readLine()) != null) {
System.out.println("line "+i+" >" + line);
i++;
}
}
catch(Exception ex) { ex.printStackTrace(); }
}
};
th.start();
int exitVal=pr.waitFor();
System.out.println("ExitValue: " + exitVal);
}
catch(Exception ex) { ex.printStackTrace(); }
--
To make sure the next file starts at a good boundary (generally 4 bytes) do the following:
int add=4-b1.length%4;
byte[] outData=new byte[b1.length+add+b2.length+];
for(i=0; i<b1.length; i++) outData[i]=b1[i];
for(i=0; i<b2.length; i++) outData[b1.length+add+i]=b2[i];
the same if you have many files.