Android Question Why this code does not work

valekuatro

Member
Licensed User
Code: Copy
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.
 
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
Back
Top