Android Question OkHttpUtils with wait for .

Polaris

Member
Licensed User
This code snippet is from the OKHttpUtils thread, which is closed to replies. Is this an error on line 8 ?

Maybe should be : File.Copy2(j.GetInputStream, out) ??



B4X:
Sub DownloadAndSaveFile (Link As String)
   Dim j As HttpJob
   j.Initialize("", Me)
   j.Download(Link)
   Wait For (j) JobDone(j As HttpJob)
   If j.Success Then
       Dim out As OutputStream = File.OpenOutput(File.DirInternal, "filename.dat", False)
     File.Copy2(job.GetInputStream, out)
     out.Close '<------ very important
   End If
   j.Release
End Sub

[CODE lang="b4x" highlight="8"]

[/CODE]
 
Top