<div class="meta" robots="noindex">

</div>

Class

# Xojo.IO.TextOutputStream

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

<div class="warning">

<div class="title">

Warning

</div>

This item was deprecated in version 2020r2. Please use `TextOutputStream</api/files/textoutputstream>` as a replacement.

</div>

## Description

Used for outputting text of a specific encoding to a file.

## Properties

<div class="rst-class">

table-centered_columns_3_and_4

</div>

| Name                                            | Type                                                 | Read-Only | Shared |
|-------------------------------------------------|------------------------------------------------------|-----------|--------|
| `Delimiter<xojo.io.textoutputstream.delimiter>` | `Text</api/deprecated/text>`                         |           |        |
| `Encoding<xojo.io.textoutputstream.encoding>`   | `TextEncoding</api/text/encoding_text/textencoding>` |           |        |

## Methods

<div class="rst-class">

table-centered_column_4

</div>

| Name                                            | Parameters                                                                                                 | Returns                                         | Shared |
|-------------------------------------------------|------------------------------------------------------------------------------------------------------------|-------------------------------------------------|--------|
| `Append<xojo.io.textoutputstream.append>`       | f As `FolderItem</api/files/folderitem>`, encoding As `TextEncoding</api/text/encoding_text/textencoding>` | `TextOutputStream</api/files/textoutputstream>` |        |
| `Close<xojo.io.textoutputstream.close>`         |                                                                                                            |                                                 |        |
| `Create<xojo.io.textoutputstream.create>`       | f As `FolderItem</api/files/folderitem>`, encoding As `TextEncoding</api/text/encoding_text/textencoding>` | `TextOutputStream</api/files/textoutputstream>` |        |
| `Flush<xojo.io.textoutputstream.flush>`         |                                                                                                            |                                                 |        |
| `Handle<xojo.io.textoutputstream.handle>`       | type As Xojo.IO.HandleTypes                                                                                | `Ptr</api/data_types/additional_types/ptr>`     |        |
| `Write<xojo.io.textoutputstream.write>`         | data As `String</api/data_types/string>`                                                                   |                                                 |        |
| `WriteLine<xojo.io.textoutputstream.writeline>` | data As `String</api/data_types/string>`                                                                   |                                                 |        |

## Property descriptions

<div id="xojo.io.textoutputstream.delimiter">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Xojo.IO.TextOutputStream.Delimiter

**Delimiter** As `Text</api/deprecated/text>`

The character used to mark the end of a line of text written to the file. If this value is not set, the OS default for EndOfLine is used.

Set the delimeter to Tab:

``` xojo
outputStream.Delimiter = &u09
```

<div id="xojo.io.textoutputstream.encoding">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Xojo.IO.TextOutputStream.Encoding

**Encoding** As `TextEncoding</api/text/encoding_text/textencoding>`

The encoding used for writing the text. Raises an exception if set to Nil.

Change the encoding to ASCII:

``` xojo
Using Xojo.Core
outputStream.Encoding = TextEncoding.ASCII
```

## Method descriptions

<div id="xojo.io.textoutputstream.append">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Xojo.IO.TextOutputStream.Append

**Append**(f As `FolderItem</api/files/folderitem>`, encoding As `TextEncoding</api/text/encoding_text/textencoding>`) As `TextOutputStream</api/files/textoutputstream>`

Opens the passed file so that text can be appended to existing text.

``` xojo
Using Xojo.Core
Using Xojo.IO

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

Var output As TextOutputStream
Try
  output = TextOutputStream.Append(f, TextEncoding.UTF8)
  output.WriteLine("This text is appended to the end of the file.")
  output.Close
Catch e As IOException
  Label1.Text = "Unable to append to file."
End Try
```

<div id="xojo.io.textoutputstream.close">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Xojo.IO.TextOutputStream.Close

**Close**

Closes the TextOutputStream. The stream is also closed automatically when it goes out of scope.

``` xojo
outputStream.Close
```

<div id="xojo.io.textoutputstream.create">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Xojo.IO.TextOutputStream.Create

**Create**(f As `FolderItem</api/files/folderitem>`, encoding As `TextEncoding</api/text/encoding_text/textencoding>`) As `TextOutputStream</api/files/textoutputstream>`

Creates a text file for so that text can be written. If the file exists, it will be erased and recreated.

Create a text file and write data to it:

``` xojo
Using Xojo.Core
Using Xojo.IO

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

Var output As TextOutputStream
Try
  output = TextOutputStream.Create(f, TextEncoding.UTF8)
  output.WriteLine("Hello, World!")
  output.Close
Catch e As IOException
  Label1.Text = "Unable to create or write to file."
End Try
```

<div id="xojo.io.textoutputstream.flush">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Xojo.IO.TextOutputStream.Flush

**Flush**

Immediately sends the contents of internal write buffers to disk or to the output stream.

``` xojo
outputStream.Flush
```

<div id="xojo.io.textoutputstream.handle">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Xojo.IO.TextOutputStream.Handle

**Handle**(type As Xojo.IO.HandleTypes) As `Ptr</api/data_types/additional_types/ptr>`

Handle returns a handle of the Type passed or -1 if the requested type cannot be retrieved.

<div id="xojo.io.textoutputstream.write">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Xojo.IO.TextOutputStream.Write

**Write**(data As `String</api/data_types/string>`)

Writes the passed data to the output stream.

``` xojo
Var outputText As Text = "This is a test."
outputStream.Write(outputText)
```

<div id="xojo.io.textoutputstream.writeline">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Xojo.IO.TextOutputStream.WriteLine

**WriteLine**(data As `String</api/data_types/string>`)

Writes the passed data to the output stream followed by the character(s) defined in Delimiter.

``` xojo
Var outputText As Text = "This is a test."
outputStream.WriteLine("1: " + outputText)
outputStream.WriteLine("2: " + outputText)
```

## Compatibility

All project types on all supported operating systems.

## See also

`Object</api/data_types/additional_types/object>` parent class; `BinaryStream</api/files/binarystream>`, `FolderItem</api/files/folderitem>`, `TextInputStream</api/files/textinputstream>` classes
