Android Question download a file and read the contents

toro1950

Active Member
Licensed User
Hi, I use this code to download and read the contents of a file
B4X:
testo="miofile.txt"
    Dim j As HttpJob
    j.Initialize("", Me)
    j.Download("https://www.miofile/foldername/" & testo)
        Wait For (j) JobDone(j As HttpJob)
    If j.Success Then
        
    Dim out As OutputStream
    out = File.OpenOutput(File.DirInternal,"Note", False)
       
    File.Copy2(J.GetInputStream,out)
        out.close
        L2.Initialize
        L2 = File.ReadList(File.DirInternal,"note")
        Label1.Text= L2.get(0)
            
    End If
It is possible to read the contents of the file without saving it
in File.DirInternal,"Note"
 
Solution
B4X:
Dim j As HttpJob
j.Initialize("", Me)
j.Download("https://sample-files.com/downloads/documents/txt/simple.txt")
Wait For (j) JobDone (j As HttpJob)
If j.Success Then
    Log(j.GetString)
Else
    Log(j.ErrorMessage)
End If
j.Release

aeric

Expert
Licensed User
Longtime User
B4X:
Dim j As HttpJob
j.Initialize("", Me)
j.Download("https://sample-files.com/downloads/documents/txt/simple.txt")
Wait For (j) JobDone (j As HttpJob)
If j.Success Then
    Log(j.GetString)
Else
    Log(j.ErrorMessage)
End If
j.Release
 
Upvote 0
Solution
Top