TextInputStream.ReadAll

From Xojo Documentation
Jump to: navigation, search
Method
TextInputStream.ReadAll ( [Encoding as TextEncoding] ) As String

Returns all of the text from the current position to the end of the file as a String.

Notes

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.

Example

This example is opens a text file that the user selects into a TextInputStream and then displays it in a TextArea.

Dim f As FolderItem
Dim dlg As OpenDialog
Dim t As TextInputStream

// create a new openDialog
dlg = New OpenDialog
// set what type of file it looks for
dlg.Filter = "text/plain"

// display the dialog
f = dlg.ShowModal

// check to make sure the user didn't click cancel
If f <> Nil Then
t = TextInputStream.Open(f)
// make sure we could open it
If t <> Nil Then
// Read all of t into myTextArea.text
MyTextArea.Text = t.ReadAll
// close the file so that other applications can use it
t.Close
Else
// the file could not be a read as a text file
MsgBox("The selected file is not a text file.")
End If
Else
// the user clicked cancel... just ignore it
End If
Personal tools
Namespaces

Variants
Actions
Main
Documentation
Community
Toolbox
Help