Package nom.tam.util

Class ArrayOutputStream

All Implemented Interfaces:
Closeable, Flushable, AutoCloseable, OutputWriter
Direct Known Subclasses:
FitsOutputStream

public class ArrayOutputStream extends BufferedOutputStream implements OutputWriter
Efficient writing of binary arrays to streams with custom binary encoding.
Since:
1.16
Author:
Attila Kovacs
See Also:
  • Constructor Details

    • ArrayOutputStream

      protected ArrayOutputStream(OutputStream o, int bufLength)
      Instantiates a new output stream for efficient array transactions. For use by subclass constructors only.
      Parameters:
      o - the underlying output stream
      bufLength - the buffer size in bytes.
    • ArrayOutputStream

      public ArrayOutputStream(OutputStream o, int bufLength, OutputEncoder java2bin)
      Instantiates a new output stream for efficient array transactions.
      Parameters:
      o - the underlying output stream
      bufLength - the buffer size in bytes.
      java2bin - the conversion from Java arrays to the binary representation in the stream.
  • Method Details

    • setEncoder

      protected void setEncoder(OutputEncoder java2bin)
      Sets the conversion from Java arrays to their binary representation in the stream. For use by subclass constructors only.
      Parameters:
      java2bin - the conversion from Java arrays to their binary representation in stream
      See Also:
    • getEncoder

      protected OutputEncoder getEncoder()
      Returns the conversion from Java arrays to their binary representation in the stream. Subclass implementeations can use this to access the required conversion when writing data to file.
      Returns:
      the conversion from Java arrays to their binary representation in stream
      See Also:
    • writeArray

      public void writeArray(Object o) throws IOException, IllegalArgumentException
      See ArrayDataOutput.writeArray(Object) for a contract of this method.
      Parameters:
      o - an array ot any type.
      Throws:
      IllegalArgumentException - if the argument is not an array or if it contains an element that is not supported for encoding.
      IOException - if there was an IO error writing to the output.