Save audio bytes in java -


here problem, i'm regularly receiving audio bytes library, write them bytearrayoutputstream and, after typing cmd, saving wav file.

the problem bytearrayoutputstream creating memory leaks because it's there (private variable) and, because reset doesn't free memory, i'm stuck.

i know there better way, don't know is.

ps: getbytes(byte[] audio) called library.

example:

public class gettinginfos() {     private bytearrayoutputstream allinfos;      public void getbytes(byte[] audio) {         allinfos.write(audio);     }     public void endrecord() {         bytearrayinputstream bais = new bytearrayinputstream(allinfos.tobytearray());         audioinputstream ais = new audioinputstream(bais, recordbotarh.output_format, allinfos.tobytearray().length);         audiosystem.write(ais, audiofileformat.type.wave, new file("file.wav"));          //i tried both of these solutions         allinfos.reset();         allinfos = null;     } } 


Comments

Popular posts from this blog

account - Script error login visual studio DefaultLogin_PCore.js -

xcode - CocoaPod Storyboard error: -