TextOutputStream.Create

From Xojo Documentation

Revision as of 21:28, 22 November 2019 by Gperlman (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Shared Method

TextOutputStream.Create(f As FolderItem) As TextOutputStream

New in 2009r4

Supported for all project types and targets.

Creates a text file for so that text can be written. The write is done by calling Write or WriteLine. Call Close when you are finished writing to the file.

Notes

If the file exists, it will be erased and recreated.

An IO error will trigger an IOException.

Sample Code

This code writes text from a TextField into a file:

Var f As FolderItem = FolderItem.ShowSaveFileDialog(FileTypes1.Text, "Create Example.txt")
If f <> Nil Then
Try
Var t As TextOutputStream = TextOutputStream.Create(f)
t.WriteLine(TextField1.Value)
t.Close
Catch e As IOException
// handle error
End Try
End If