+ 1
Copy file from uri
In my app I have to copy a file selected by the user in my apps's folder. With a contenresolver I get an Inputstream of the uri, and I open a Fileoutputstream to my destination. After buffering both streams, I simply read each byte of the input and write it into the output. It works but the last round about 200 bytes get cut causing the file to get currupt. Jas anyone an idea what causes this? ps.: I'm executing this with an Asynctask.
1 Réponse
+ 1
Close file handles? If this doesn't work, look for a 'flush' instruction.
In languages that don't clean up for you (or async threads that get killed instead of shut down), last block data loss/garbage cluster is typical if your handles are open when you fall off the end of the program, especially when buffering.