LordZenzo Well-Known Member Licensed User Longtime User Aug 1, 2017 #1 I have a problem with file.copy2 I use the command to copy a sqlite db from the library jar file But apparently the copy appears corrupt I did dozens of tests also to copy the file from other locations, if I use the file.copy the copy is perfect if I use the file.copy2 always appears corrupt
I have a problem with file.copy2 I use the command to copy a sqlite db from the library jar file But apparently the copy appears corrupt I did dozens of tests also to copy the file from other locations, if I use the file.copy the copy is perfect if I use the file.copy2 always appears corrupt
Erel B4X founder Staff member Licensed User Longtime User Aug 1, 2017 #2 Can you post the code? Upvote 0
DonManfred Expert Licensed User Longtime User Aug 1, 2017 #3 Examplecode from another thread... Just to show the principle Code: Dim out As OutputStream out = File.OpenOutput(File.DirRootExternal,URLwaiting.GetValueAt(i),False) File.Copy2(HttpUtils.GetInputStream(URLwaiting.GetKeyAt(i)),out) out.close Don´t forget to CLOSE the outtputstream Upvote 0
Examplecode from another thread... Just to show the principle Code: Dim out As OutputStream out = File.OpenOutput(File.DirRootExternal,URLwaiting.GetValueAt(i),False) File.Copy2(HttpUtils.GetInputStream(URLwaiting.GetKeyAt(i)),out) out.close Don´t forget to CLOSE the outtputstream
LordZenzo Well-Known Member Licensed User Longtime User Aug 1, 2017 #4 Ok, that's how it works But file.copy2 should close the FileOutputStreem otherwise it is not a copy but more Upvote 0
Ok, that's how it works But file.copy2 should close the FileOutputStreem otherwise it is not a copy but more
Erel B4X founder Staff member Licensed User Longtime User Aug 1, 2017 #5 LordZenzo said: But file.copy2 should close the FileOutputStreem otherwise it is not a copy but more Click to expand... No it doesn't. Only the InputStream is closed: https://www.b4x.com/android/forum/pages/results/?query=file.copy2 File.Copy2 copies the input stream to the output stream. It doesn't close the output stream to allow developers to copy more data if needed. Upvote 0
LordZenzo said: But file.copy2 should close the FileOutputStreem otherwise it is not a copy but more Click to expand... No it doesn't. Only the InputStream is closed: https://www.b4x.com/android/forum/pages/results/?query=file.copy2 File.Copy2 copies the input stream to the output stream. It doesn't close the output stream to allow developers to copy more data if needed.