StreamBase CLASS

A stream class base that implements most interface details. The subclasses need only implement the actual I/O operation.

This stream doesn't support marking.

Parent Class

Parent Interfaces

All Members


TypeNameSignature
methodcanMarkpublic bool canMark()
methodclosepublic void close()
methodflushpublic void flush()
methodmarkpublic void mark()
methodreadpublic int read()
methodreadpublic int read(byte[], int, int)
methodresetpublic void reset()
methodskippublic int skip(int)
methodwritepublic void write(byte)
methodwritepublic void write(byte[], int, int)

Methods


public bool canMark()

(INHERITED DOC)

Whether this stream supports position-manipulating operations. This method governs mark, reset.

Returns

  • True if this stream supports position-manipulating operations.

public void close()

(INHERITED DOC)

Close the stream. Once the stream is closed it cannot be re-opened.


public void flush()

(INHERITED DOC)

Flush the stream. This will materialize all the data copy which may so far have only occurred inside in-memory data buffer, which is usually an implementation detail of the stream. It's best practice for the user to call this method between writing calls, as well as at the conclusion of data copy logic, to ensure all the data have effectively flown into the sink.


public void mark()

(INHERITED DOC)

Mark the current position of stream. Calling reset() will move the stream pointer to the marked position.

If canMark() return false, this method will throw IOException.


public int read()

(INHERITED DOC)

Read one byte from the stream.

This will move forward the stream pointer by one. If canRead() return false, this method will throw IOException.

Returns

  • The byte read from the stream. -1 if reaching the end.

public int read(byte[] buffer, int offset, int count)

(INHERITED DOC)

Try to read desired number of bytes from the stream into the given buffer, starting from the offset and not exceeding the buffer's capacity. This will move forward the stream pointer by the number of bytes actually read. If the stream hits the end, or the buffer runs short of room, before reading the specified count, only those bytes will be read, making the returned value less than the count argument.

This method moves forward the stream pointer by the count equal to returned value. If canRead() return false, this method will throw IOException.

Parameters

  • buffer The byte buffer to hold the data to be read from the stream.
  • offset The offset on buffer to start filling the data in.
  • count The desired number of bytes to read.

Returns

  • The count of bytes read from the stream. -1 if reaching the end without any bytes read.

public void reset()

(INHERITED DOC)

Move the stream pointer to the position marked by mark().

If canMark() return false, this method will throw IOException.


public int skip(int count)

(INHERITED DOC)

Instead of reading, try to skip desired number of bytes from the stream. This will move forward the stream pointer by the number of bytes actually read. If the stream hits the end before reading the specified count, only those bytes will be skipped, making the returned value less than the count argument.

This method moves forward the stream pointer by the count equal to returned value. If canRead() return false, this method will throw IOException.

Parameters

  • count The desired number of bytes to skip.

Returns

  • The count of bytes skipped. -1 if reaching the end without any bytes skipped.

public void write(byte data)

(INHERITED DOC)

Write one byte to the stream.

This will move forward the stream pointer by one. If canWrite() return false, this method will throw IOException.

Parameters

  • data The single byte to write to this stream.

public void write(byte[] buffer, int offset, int count)

(INHERITED DOC)

Try to write desired number of bytes into the stream from the given buffer, starting from the offset and not exceeding the buffer's capacity. This will move forward the stream pointer by the number of bytes actually read. If the buffer hits the end before reading the specified count, only those bytes will be written, making the returned value less than the count argument.

This method moves forward the stream pointer by the count equal to returned value. If canWrite() return false, this method will throw IOException.

Parameters

  • buffer The byte buffer which holds the data to write into the stream.
  • offset The offset on the buffer from which the data will be pulled.
  • count The desired number of bytes to write.