From Xojo Documentation


TextInputStream.ReadLine([Encoding as TextEncoding]) As String

Supported for all project types and targets.

Returns the next line of text (as a string) from the TextInputstream. Any valid end-of-line indicator is used to identify a line.


The optional Encoding parameter enables you to specify the encoding of the text. If you pass Nil, the default encoding is used. This is usually UTF-8, unless it was set to another encoding via an assignment statement. If you want to set the encoding to Nil, use the Encoding property instead.


This example reads the rows and columns of data from a tab-delimited text file into a ListBox:

Var f As FolderItem
Var textInput As TextInputStream
Var rowFromFile, oneCell As String

f = FolderItem.ShowOpenFileDialog("text/plain") // defined as a FileType
If f <> Nil Then
textInput = TextInputStream.Open(f)
textInput.Encoding = Encodings.UTF8
rowFromFile = textInput.ReadLine
If ListBox1.ColumnCount < rowFromFile.CountFields(Chr(9)) Then
ListBox1.ColumnCount = rowFromFile.CountFields(Chr(9))
End If

ListBox1.AddRow(NthField(rowFromFile, Chr(9), 1))
For i As Integer =1 To rowFromFile.CountFields(Chr(9))
oneCell = rowFromFile.NthField(Chr(9), i)
ListBox1.CellValueAt(ListBox1.SelectedRowIndex - 1, i - 1) = oneCell
Loop Until textInput.EndOfFile
End If