Xojo.IO.TextInputStream.ReadLine

From Xojo Documentation

Method

Xojo.IO.TextInputStream.ReadLine() As Text

Supported for all project types and targets.

Reads bytes from the stream until an EOL character is encountered and returns them as a Text object.

Exceptions

  • IOException if there is not enough memory available or the stream is not open.

Sample Code

Load each line of the text file into an array:

Using Xojo.Core
Using Xojo.IO

Var f As FolderItem
f = SpecialFolder.Documents.Child("SaveData.txt")

If Not f.Exists Then
// Cannot read the file if it does not exist
Return
End If

Var errorText As Text
Var lines() As Text
Try
Var input As TextInputStream
input = TextInputStream.Open(f, TextEncoding.UTF8)
While Not input.EOF
lines.AddRow(input.ReadLine)
Wend
input.Close
Catch e As IOException
errorText = "File IO Error: " + e.Reason
End Try