I am writing the file output on Kotlin.
If you check the operation, there is no error and no file is generated even though it is written.
file.createNewFile()
If you first generate and write the file in , the file is still empty.
Permission is also specified (if there is a problem, it will be an error)
Please let me know if anyone knows how to solve it.
var file=TMP_AUDIO_FILE
Log.i("TAG", ">>>>" + file.absolutePath)
valsData=ShortArray(BUFFER_SIZE/2)
try{
varos=openFileOutput(file.absolutePath.replace("/", " ""), MODE_PRIVATE)
while(isRecording){
var readSize=audioRecord.read(sData,0,sData.count())
if(readSize>0){
valveData —ByteArray=short2byte(sData)
os.write(bData,0,readSize)
os.flush()
}
}
audioRecord.stop()
os.flush()
os.close()
} catch(e:Exception){
e.printStackTrace()
}
openFileOutput(file.absolutePath.replace("/", " ""), MODE_PRIVATE)
was changed to FileOutputStream(file.absoluteFile)
, and it was written out.
© 2024 OneMinuteCode. All rights reserved.