You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The code below works well, and the jpg file can be open:
val inputStream = context.contentResolver.openInputStream(mediaFile.uri)
val outputStream = BufferedOutputStream(UsbFileOutputStream(file), chunkSize)
val buffer = ByteArray(chunkSize)
var len = 0
while (inputStream!!.read(buffer).also { len = it } != -1) {
outputStream.write(buffer, 0, len)
}
outputStream.flush()
outputStream.close()
inputStream.close()
But when I want to improve the performance, so I changed the buffer size of BufferedOutputStream to 10 * chunkSize:
val outputStream = BufferedOutputStream(UsbFileOutputStream(file), 10 * chunkSize)
The jpg file can not be opened, may be it had been broken.
Expected behavior
The jpg file saved in USB device should be opened.
Actual behavior
The jpg file saved in USB device can not be opened, maybe it had been broken
I don't know how to solve this problem, would you help me? Thank you very much.
The text was updated successfully, but these errors were encountered:
Problem
The code below works well, and the jpg file can be open:
But when I want to improve the performance, so I changed the buffer size of BufferedOutputStream to 10 * chunkSize:
The jpg file can not be opened, may be it had been broken.
Expected behavior
The jpg file saved in USB device should be opened.
Actual behavior
The jpg file saved in USB device can not be opened, maybe it had been broken
I don't know how to solve this problem, would you help me? Thank you very much.
The text was updated successfully, but these errors were encountered: