---
title: "IO.Stream"
description: "Abstract IO stream prototype."
canonical_url: "https://www.zeyos.com/zymba/ref/io/io-stream"
markdown_url: "https://www.zeyos.com/ai/guide/zymba/ref/io/io-stream.md"
section: "zymba-reference"
authority: "reference"
language: "en"
source_repository: "https://cloud.zeyos.com/__doc/zymbaref.json"
source_sha256: "05a361c6ddc32e74f4a6dc16fd06f218210ff1b7ce57f26ca1994bfffc407915"
---

# IO.Stream

## IO.Stream

```
object @IO.Stream(@Base) {
	MODE_READ;
	MODE_WRITE;
	canRead(): bool {}
	canSeek(): bool {}
	canWrite(): bool {}
	close() {}
	copyTo(@IO.Stream $stream, ?int $length): int {}
	disableBlocking(): $this {}
	echo(?int $length): int {}
	echoAll(): int {}
	echoLine(): int {}
	enableBlocking(): $this {}
	exit() {}
	flush(): $this {}
	getPosition(): int {}
	getURI(): string {}
	hasMore(): bool {}
	hasTimedOut(): bool {}
	isBlocking(): bool {}
	isLocal(): bool {}
	next(): object {}
	overwrite(string $string): int {}
	pollExceptional(): bool {}
	pollRead(): bool {}
	pollWrite(): bool {}
	read(?int $length): string {}
	readAll(): string {}
	readLine(): string {}
	readLineCSV(string $delimiter): object {}
	reset(): $this {}
	seek(int $position): $this {}
	seekEnd(): $this {}
	setReadBuffer(int $size): $this {}
	setTimeout(int $timeout): $this {}
	setWriteBuffer(int $size): $this {}
	skip(int $offset): $this {}
	toString(): string {}
	truncate(int $size): $this {}
	write(string $string, ?int $length): int {}
	writeFormatted(string $format, ...$arguments): int {}
	writeLine(string $string): int {}
	writeLineCSV(object $array, string $delimiter): int {}
}
```

**Abstract IO stream prototype.**

### Prototype

**[Base](#)**

## Methods


### `$this.canRead()`


Determines whether this stream can be read from.

```code
$this.canRead(): bool
```

##### Returns

| Type | Value |
| --- | ---  |
| `bool` |  |




### `$this.canSeek()`


Determines whether this stream can be sought.

```code
$this.canSeek(): bool
```

##### Returns

| Type | Value |
| --- | ---  |
| `bool` |  |




### `$this.canWrite()`


Determines whether this stream can be written to.

```code
$this.canWrite(): bool
```

##### Returns

| Type | Value |
| --- | ---  |
| `bool` |  |




### `$this.close()`


Closes this stream and frees its associated resources.

```code
$this.close(): void
```




### `$this.copyTo()`


```code
$this.copyTo(@IO.Stream $stream, ?int $length): int
```

##### Parameters

| Name | Type | Value | Default |
| --- | --- | --- | --- |
| stream | `@IO.Stream`  |  | null |
| length | `?int`  |  | maximum length |

##### Returns

| Type | Value |
| --- | ---  |
| `int` |  |




### `$this.disableBlocking()`


Disables blocking mode for this stream.

```code
$this.disableBlocking(): this
```

##### Returns

| Type | Value |
| --- | ---  |
| `$this` |  |




### `$this.echo()`


Outputs the content of this stream up to a specific byte-based length and returns the number of bytes outputted.

```code
$this.echo(?int $length): int
```

##### Parameters

| Name | Type | Value | Default |
| --- | --- | --- | --- |
| length | `?int`  |  | maximum length |

##### Returns

| Type | Value |
| --- | ---  |
| `int` |  |




### `$this.echoAll()`


```code
$this.echoAll(): int
```

##### Returns

| Type | Value |
| --- | ---  |
| `int` |  |




### `$this.echoLine()`


Outputs the content of this stream as far as and including the next end-of-line sequence and returns the number of bytes outputted.

```code
$this.echoLine(): int
```

##### Returns

| Type | Value |
| --- | ---  |
| `int` |  |




### `$this.enableBlocking()`


Enables blocking mode for this stream.

```code
$this.enableBlocking(): this
```

##### Returns

| Type | Value |
| --- | ---  |
| `$this` |  |




### `$this.exit()`


Closes this stream and frees its associated resources for the purpose of contextualization.

```code
$this.exit(): void
```




### `$this.flush()`


Flushes the write buffer of this stream.

```code
$this.flush(): this
```

##### Returns

| Type | Value |
| --- | ---  |
| `$this` |  |




### `$this.getPosition()`


Gets the current position within this stream as the number of bytes from its beginning.

```code
$this.getPosition(): int
```

##### Returns

| Type | Value |
| --- | ---  |
| `int` |  |




### `$this.getURI()`


Gets the URI associated with this stream.

```code
$this.getURI(): string
```

##### Returns

| Type | Value |
| --- | ---  |
| `string` |  |




### `$this.hasMore()`


Determines whether this stream has more content.

```code
$this.hasMore(): bool
```

##### Returns

| Type | Value |
| --- | ---  |
| `bool` |  |




### `$this.hasTimedOut()`


Determines whether this stream has timed out.

```code
$this.hasTimedOut(): bool
```

##### Returns

| Type | Value |
| --- | ---  |
| `bool` |  |




### `$this.isBlocking()`


Determines whether this stream is in blocking mode.

```code
$this.isBlocking(): bool
```

##### Returns

| Type | Value |
| --- | ---  |
| `bool` |  |




### `$this.isLocal()`


Determines whether this stream is local.

```code
$this.isLocal(): bool
```

##### Returns

| Type | Value |
| --- | ---  |
| `bool` |  |




### `$this.next()`


Reads the content of this stream as far as and including the next end-of-line sequence for the purpose of iteration.

```code
$this.next(): object
```

##### Returns

| Type | Value |
| --- | ---  |
| `object` | [position: line] |
| `null` |  |




### `$this.overwrite()`


```code
$this.overwrite(string $string): int
```

##### Parameters

| Name | Type | Value | Default |
| --- | --- | --- | --- |
| string | `string`  |  | "" |

##### Returns

| Type | Value |
| --- | ---  |
| `int` |  |




### `$this.pollExceptional()`


```code
$this.pollExceptional(): bool
```

##### Returns

| Type | Value |
| --- | ---  |
| `bool` |  |




### `$this.pollRead()`


```code
$this.pollRead(): bool
```

##### Returns

| Type | Value |
| --- | ---  |
| `bool` |  |




### `$this.pollWrite()`


```code
$this.pollWrite(): bool
```

##### Returns

| Type | Value |
| --- | ---  |
| `bool` |  |




### `$this.read()`


Reads the content of this stream up to a specific byte-based length.

```code
$this.read(?int $length): string
```

##### Parameters

| Name | Type | Value | Default |
| --- | --- | --- | --- |
| length | `?int`  |  | maximum length |

##### Returns

| Type | Value |
| --- | ---  |
| `string` |  |




### `$this.readAll()`


Reads the entire content of this stream.

```code
$this.readAll(): string
```

##### Returns

| Type | Value |
| --- | ---  |
| `string` |  |




### `$this.readLine()`


Reads the content of this stream as far as and including the next end-of-line sequence.

```code
$this.readLine(): string
```

##### Returns

| Type | Value |
| --- | ---  |
| `string` |  |
| `null` |  |




### `$this.readLineCSV()`


```code
$this.readLineCSV(string $delimiter): object
```

##### Parameters

| Name | Type | Value | Default |
| --- | --- | --- | --- |
| delimiter | `string`  |  | ";" |

##### Returns

| Type | Value |
| --- | ---  |
| `object` | [value, ...] |
| `null` |  |




### `$this.reset()`


```code
$this.reset(): this
```

##### Returns

| Type | Value |
| --- | ---  |
| `$this` |  |




### `$this.seek()`


```code
$this.seek(int $position): this
```

##### Parameters

| Name | Type | Value | Default |
| --- | --- | --- | --- |
| position | `int`  |  | 0 |

##### Returns

| Type | Value |
| --- | ---  |
| `$this` |  |




### `$this.seekEnd()`


```code
$this.seekEnd(): this
```

##### Returns

| Type | Value |
| --- | ---  |
| `$this` |  |




### `$this.setReadBuffer()`


Sets the read buffer size of this stream to a specific number of bytes.

```code
$this.setReadBuffer(int $size): this
```

##### Parameters

| Name | Type | Value | Default |
| --- | --- | --- | --- |
| size | `int`  |  | 0 |

##### Returns

| Type | Value |
| --- | ---  |
| `$this` |  |




### `$this.setTimeout()`


Sets the timeout period of this stream to a specific number of seconds.

```code
$this.setTimeout(int $timeout): this
```

##### Parameters

| Name | Type | Value | Default |
| --- | --- | --- | --- |
| timeout | `int`  |  | 60 |

##### Returns

| Type | Value |
| --- | ---  |
| `$this` |  |




### `$this.setWriteBuffer()`


Sets the write buffer size of this stream to a specific number of bytes.

```code
$this.setWriteBuffer(int $size): this
```

##### Parameters

| Name | Type | Value | Default |
| --- | --- | --- | --- |
| size | `int`  |  | 0 |

##### Returns

| Type | Value |
| --- | ---  |
| `$this` |  |




### `$this.skip()`


```code
$this.skip(int $offset): this
```

##### Parameters

| Name | Type | Value | Default |
| --- | --- | --- | --- |
| offset | `int`  |  | 1 |

##### Returns

| Type | Value |
| --- | ---  |
| `$this` |  |




### `$this.toString()`


Converts this stream to a string by returning its associated URI.

```code
$this.toString(): string
```

##### Returns

| Type | Value |
| --- | ---  |
| `string` |  |




### `$this.truncate()`


Truncates this stream to a specific size in number of bytes.

```code
$this.truncate(int $size): this
```

##### Parameters

| Name | Type | Value | Default |
| --- | --- | --- | --- |
| size | `int`  |  | 0 |

##### Returns

| Type | Value |
| --- | ---  |
| `$this` |  |




### `$this.write()`


Writes a string to this stream up to a specific byte-based length and returns the number of bytes written.

```code
$this.write(string $string, ?int $length): int
```

##### Parameters

| Name | Type | Value | Default |
| --- | --- | --- | --- |
| string | `string`  |  | "" |
| length | `?int`  |  | maximum length |

##### Returns

| Type | Value |
| --- | ---  |
| `int` |  |




### `$this.writeFormatted()`


Writes a formatted string to this stream with "printf"-compatible format specifiers ("%...") substituted with variadic arguments.

```code
$this.writeFormatted(string $format, variadic $arguments): int
```

##### Parameters

| Name | Type | Value | Default |
| --- | --- | --- | --- |
| format | `string`  |  | "" |
| arguments | `variadic`  |  | ... |

##### Returns

| Type | Value |
| --- | ---  |
| `int` |  |




### `$this.writeLine()`


Writes a string appended by an end-of-line sequence to this stream and returns the number of bytes written.

```code
$this.writeLine(string $string): int
```

##### Parameters

| Name | Type | Value | Default |
| --- | --- | --- | --- |
| string | `string`  |  | "" |

##### Returns

| Type | Value |
| --- | ---  |
| `int` |  |




### `$this.writeLineCSV()`


```code
$this.writeLineCSV(object $array, string $delimiter): int
```

##### Parameters

| Name | Type | Value | Default |
| --- | --- | --- | --- |
| array | `object`  | [value, ...] | [] |
| delimiter | `string`  |  | ";" |

##### Returns

| Type | Value |
| --- | ---  |
| `int` |  |
