# FileOutputStreamSeekableMuxerOutput

Artifact: [androidx.media3:media3-muxer](https://developer.android.com/jetpack/androidx/releases/media3) [View Source](https://cs.android.com/search?q=file:androidx/media3/muxer/FileOutputStreamSeekableMuxerOutput.java+class:androidx.media3.muxer.FileOutputStreamSeekableMuxerOutput)

*** ** * ** ***


```
@UnstableApi
public final class FileOutputStreamSeekableMuxerOutput implements SeekableMuxerOutput
```

<br />

*** ** * ** ***

An implementation of `https://developer.android.com/reference/androidx/media3/muxer/SeekableMuxerOutput` that writes to a `https://developer.android.com/reference/java/io/FileOutputStream.html`.

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/androidx/media3/muxer/FileOutputStreamSeekableMuxerOutput#FileOutputStreamSeekableMuxerOutput(java.io.FileOutputStream)(https://developer.android.com/reference/java/io/FileOutputStream.html fileOutputStream)` Creates an instance. |

| ### Public methods |
|---|---|
| `void` | `https://developer.android.com/reference/androidx/media3/muxer/FileOutputStreamSeekableMuxerOutput#close()()` |
| `long` | `https://developer.android.com/reference/androidx/media3/muxer/FileOutputStreamSeekableMuxerOutput#getPosition()()` Returns the current position in the output. |
| `long` | `https://developer.android.com/reference/androidx/media3/muxer/FileOutputStreamSeekableMuxerOutput#getSize()()` Returns the total size of the output. |
| `boolean` | `https://developer.android.com/reference/androidx/media3/muxer/FileOutputStreamSeekableMuxerOutput#isOpen()()` |
| `void` | `https://developer.android.com/reference/androidx/media3/muxer/FileOutputStreamSeekableMuxerOutput#setPosition(long)(long position)` Sets the current position in the output for subsequent `https://developer.android.com/reference/java/nio/channels/WritableByteChannel.html#write(java.nio.ByteBuffer)` operations. |
| `void` | `https://developer.android.com/reference/androidx/media3/muxer/FileOutputStreamSeekableMuxerOutput#truncate(long)(long size)` Truncates the output to the specified size. |
| `int` | `https://developer.android.com/reference/androidx/media3/muxer/FileOutputStreamSeekableMuxerOutput#write(java.nio.ByteBuffer)(https://developer.android.com/reference/java/nio/ByteBuffer.html src)` |

### Inherited methods

From [androidx.media3.muxer.SeekableMuxerOutput](https://developer.android.com/reference/androidx/media3/muxer/SeekableMuxerOutput) `static https://developer.android.com/reference/androidx/media3/muxer/SeekableMuxerOutput` `https://developer.android.com/reference/androidx/media3/muxer/SeekableMuxerOutput#of(java.io.FileOutputStream)(https://developer.android.com/reference/java/io/FileOutputStream.html fileOutputStream)`

Creates a `https://developer.android.com/reference/androidx/media3/muxer/SeekableMuxerOutput` from the given `https://developer.android.com/reference/java/io/FileOutputStream.html`.
`static https://developer.android.com/reference/androidx/media3/muxer/SeekableMuxerOutput` `https://developer.android.com/reference/androidx/media3/muxer/SeekableMuxerOutput#of(java.lang.String)(https://developer.android.com/reference/java/lang/String.html filePath)`

Creates a `https://developer.android.com/reference/androidx/media3/muxer/SeekableMuxerOutput` from the given file path.
`static https://developer.android.com/reference/androidx/media3/muxer/SeekableMuxerOutput` `https://developer.android.com/reference/androidx/media3/muxer/SeekableMuxerOutput#of(android.os.ParcelFileDescriptor)(https://developer.android.com/reference/android/os/ParcelFileDescriptor.html pfd)`

Creates a `https://developer.android.com/reference/androidx/media3/muxer/SeekableMuxerOutput` from the given `https://developer.android.com/reference/android/os/ParcelFileDescriptor.html`.

## Public constructors

### FileOutputStreamSeekableMuxerOutput

```
public FileOutputStreamSeekableMuxerOutput(FileOutputStream fileOutputStream)
```

Creates an instance.

| Parameters |
|---|---|
| `https://developer.android.com/reference/java/io/FileOutputStream.html fileOutputStream` | The `https://developer.android.com/reference/java/io/FileOutputStream.html` to write output to. |

## Public methods

### close

```
public void close()
```

| Throws |
|---|---|
| `https://developer.android.com/reference/java/io/IOException.html` |   |

### getPosition

```
public long getPosition()
```

Returns the current position in the output.

This refers to the byte offset at which bytes will be written on the next `https://developer.android.com/reference/java/nio/channels/WritableByteChannel.html#write(java.nio.ByteBuffer)` call.

| Returns |
|---|---|
| `long` | The current position in bytes from the beginning of the output. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/io/IOException.html` | If an error occurs while getting the position. |

### getSize

```
public long getSize()
```

Returns the total size of the output.

| Returns |
|---|---|
| `long` | The total size of the output in bytes. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/io/IOException.html` | If an error occurs while getting the size. |

### isOpen

```
public boolean isOpen()
```

### setPosition

```
public void setPosition(long position)
```

Sets the current position in the output for subsequent `https://developer.android.com/reference/java/nio/channels/WritableByteChannel.html#write(java.nio.ByteBuffer)` operations.

| Parameters |
|---|---|
| `long position` | The new position in bytes from the beginning of the output. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/io/IOException.html` | If an error occurs while setting the position. |

### truncate

```
public void truncate(long size)
```

Truncates the output to the specified size.

If the current position (for writing) is beyond the new size, it is set to the new size.

| Parameters |
|---|---|
| `long size` | The new size of the output in bytes. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/io/IOException.html` | If an error occurs while truncating the output. |

### write

```
public int write(ByteBuffer src)
```

| Throws |
|---|---|
| `https://developer.android.com/reference/java/io/IOException.html` |   |