TextInputStream.ReadAll

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

Returns all of the text (as a string) from the TextInputStream.

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"

//run 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 applicaitons 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