Read the lines into a list and return the value index-1
Depends on the fact the list is not too big and it reads the hole file into a list.
Alternatively you can use Stringreader to read lines until you reach the wanted index. Probably much slower then using a List.
B4X:
Log(GetLine(1))
Log(GetLine(10))
Sub GetLine(idx As Int) As String
Dim text As List = File.ReadList(File.DirAssets,"test.txt")
If text.IsInitialized And text.Size>=idx-1 Then
Return text.Get(idx-1)
End If
Return ""
End Sub
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.