Android Question Why this code does not work

valekuatro

Member
Licensed User
B4X:
If HttpUtils.IsSuccess(FileUrl) Then
        File.Copy2(HttpUtils.GetInputStream(FileUrl),File.OpenOutput(File.DirRootExternal,FileName,False))
        ToastMessageShow("Done", False)
    Else
        ToastMessageShow("Error!", False)
    End If

It throw no errors, download the file, size correct, but content of the file is incomplete or bad.
 

DonManfred

Expert
Licensed User
Longtime User
File. Copy2 (In As java.io.InputStream, Out As java.io_OutputStream)
Copies all the available data from the input stream into the output stream.
The input stream is automatically closed at the end.

The inputstream are automatically closed.
The outputstream not. Close the outputstream.
 
Upvote 0
Top