# Class PositionalOutputStream

java.lang.Object
java.io.OutputStream
htsjdk.samtools.util.PositionalOutputStream

All Implemented Interfaces:
  `LocationAware, Closeable, Flushable, AutoCloseable`

public final class PositionalOutputStream extends OutputStream implements LocationAware
Wraps output stream in a manner which keeps track of the position within the file and allowing writes at arbitrary points

## Constructor Summary

Constructors
Constructor
Description
`PositionalOutputStream(OutputStream out)`

## Method Summary

Modifier and Type
Method
Description
`void`
`close()`
`final long`
`getPosition()`
The current offset, in bytes, of this stream/writer/file.
`final void`
`write(byte[] bytes)`
`final void`
`write(byte[] bytes, int startIndex, int numBytes)`
`final void`
`write(int c)`

### Methods inherited from class OutputStream

`flush, nullOutputStream`

### Methods inherited from class Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### PositionalOutputStream

public PositionalOutputStream(OutputStream out)

## Method Details

### write

public final void write(byte[] bytes) throws IOException

Overrides:
  `write` in class `OutputStream`
Throws:
  `IOException`

### write

public final void write(byte[] bytes, int startIndex, int numBytes) throws IOException

Overrides:
  `write` in class `OutputStream`
Throws:
  `IOException`

### write

public final void write(int c) throws IOException

Specified by:
  `write` in class `OutputStream`
Throws:
  `IOException`

### getPosition

public final long getPosition()
Description copied from interface: `LocationAware`
The current offset, in bytes, of this stream/writer/file. Or, if this is an iterator/producer, the offset (in bytes) of the END of the most recently returned record (since a produced record corresponds to something that has been read already). See class javadoc for more. Note that for BGZF files, this does not represent an actually file position, but a virtual file pointer.

Specified by:
  `getPosition` in interface `LocationAware`

### close

public void close() throws IOException

Specified by:
  `close` in interface `AutoCloseable`
Specified by:
  `close` in interface `Closeable`
Overrides:
  `close` in class `OutputStream`
Throws:
  `IOException`