B4J Question Read line x line from text file

cstangor

Member
Licensed User
Longtime User
Can I read from a text file line by line? not file.readstring or file.readlist because the file is too big.

Thanks in advance
 

Daestrum

Expert
Licensed User
Longtime User
Try
B4X:
    Dim fr,br As JavaObject
    fr.InitializeNewInstance("java.io.FileReader",Array("c:/temp/testinput.txt")) 
    br.InitializeNewInstance("java.io.BufferedReader",Array(fr))
    Dim st As String =     br.RunMethod("readLine",Null)
    Do While st  <> "null"    ' will be "null" at end of file
        Log(st)
        st = br.RunMethod("readLine",Null)
    Loop
    br.RunMethod("close",Null)
 
Upvote 0
Top