Class IRODSDataObjectOutputStream

java.lang.Object
java.io.OutputStream
org.irods.irods4j.high_level.io.IRODSDataObjectOutputStream
All Implemented Interfaces:
Closeable, Flushable, AutoCloseable

public class IRODSDataObjectOutputStream extends OutputStream
A buffered output stream that makes it easy to write iRODS data objects.
Since:
0.1.0
  • Constructor Details

    • IRODSDataObjectOutputStream

      public IRODSDataObjectOutputStream()
      Initializes a new instance with a buffer size of 65536 bytes.
      Since:
      0.1.0
    • IRODSDataObjectOutputStream

      public IRODSDataObjectOutputStream(int bufferSize)
      Initializes a new instance with a custom buffer size.
      Parameters:
      bufferSize - The size of the internal buffer.
      Since:
      0.1.0
    • IRODSDataObjectOutputStream

      public IRODSDataObjectOutputStream(IRODSApi.RcComm comm, String logicalPath, boolean truncate, boolean append) throws IOException, IRODSException
      Initializes a new instance and opens a data object for writing.

      If not replica exists, it is created.

      The internal buffer will have a size of 65536.

      Parameters:
      comm - The connection to the iRODS server.
      logicalPath - The absolute logical path to a data object.
      truncate - Truncate the replica.
      append - Append new data to replica.
      Throws:
      IOException
      IRODSException
      Since:
      0.1.0
    • IRODSDataObjectOutputStream

      public IRODSDataObjectOutputStream(IRODSApi.RcComm comm, String logicalPath, String rootResourceName, boolean truncate, boolean append) throws IOException, IRODSException
      Initializes a new instance and opens a replica for writing.

      If not replica exists, it is created.

      The internal buffer will have a size of 65536.

      Parameters:
      comm - The connection to the iRODS server.
      logicalPath - The absolute logical path to a data object.
      rootResourceName - The root resource which contains the target replica.
      truncate - Truncate the replica.
      append - Append new data to replica.
      Throws:
      IOException
      IRODSException
      Since:
      0.1.0
    • IRODSDataObjectOutputStream

      public IRODSDataObjectOutputStream(IRODSApi.RcComm comm, String logicalPath, long replicaNumber, boolean truncate, boolean append) throws IOException, IRODSException
      Initializes a new instance and opens a specific replica for writing.

      This operation will fail if the target replica does not exist.

      The internal buffer will have a size of 65536.

      Parameters:
      comm - The connection to the iRODS server.
      logicalPath - The absolute logical path to a data object.
      replicaNumber - The replica number which identifies the target replica.
      truncate - Truncate the replica.
      append - Append new data to replica.
      Throws:
      IOException
      IRODSException
      Since:
      0.1.0
    • IRODSDataObjectOutputStream

      public IRODSDataObjectOutputStream(IRODSApi.RcComm comm, String replicaToken, String logicalPath, long replicaNumber, boolean truncate, boolean append) throws IOException, IRODSException
      Initializes a new instance and opens a specific replica for parallel writing.

      The replica is assumed to have been opened prior to this call.

      The internal buffer will have a size of 65536.

      Parameters:
      comm - The connection to the iRODS server.
      replicaToken - The replica access token of the primary output stream.
      logicalPath - The absolute logical path to a data object.
      replicaNumber - The replica number which identifies the target replica.
      truncate - Truncate the replica.
      append - Append new data to replica.
      Throws:
      IOException
      IRODSException
      Since:
      0.1.0
  • Method Details

    • open

      public void open(IRODSApi.RcComm comm, String logicalPath, boolean truncate, boolean append) throws IOException, IRODSException
      Opens a data object for writing.

      If not replica exists, it is created.

      Parameters:
      comm - The connection to the iRODS server.
      logicalPath - The absolute logical path to a data object.
      truncate - Truncate the replica.
      append - Append new data to replica.
      Throws:
      IOException
      IRODSException
      Since:
      0.1.0
    • open

      public void open(IRODSApi.RcComm comm, String logicalPath, String rootResourceName, boolean truncate, boolean append) throws IOException, IRODSException
      Opens a replica for writing.

      If no replica exists, it is created.

      Parameters:
      comm - The connection to the iRODS server.
      logicalPath - The absolute logical path to a data object.
      rootResourceName - The root resource which contains the target replica.
      truncate - Truncate the replica.
      append - Append new data to replica.
      Throws:
      IOException
      IRODSException
      Since:
      0.1.0
    • open

      public void open(IRODSApi.RcComm comm, String logicalPath, long replicaNumber, boolean truncate, boolean append) throws IOException, IRODSException
      Opens a specific replica for writing.

      This operation will fail if the target replica does not exist.

      Parameters:
      comm - The connection to the iRODS server.
      logicalPath - The absolute logical path to a data object.
      replicaNumber - The replica number which identifies the target replica.
      truncate - Truncate the replica.
      append - Append new data to replica.
      Throws:
      IOException
      IRODSException
      Since:
      0.1.0
    • open

      public void open(IRODSApi.RcComm comm, String replicaToken, String logicalPath, long replicaNumber, boolean truncate, boolean append) throws IOException, IRODSException
      Opens a specific replica for parallel writing.

      The replica is assumed to have been opened prior to this call.

      Parameters:
      comm - The connection to the iRODS server.
      replicaToken - The replica access token of the primary output stream.
      logicalPath - The absolute logical path to a data object.
      replicaNumber - The replica number which identifies the target replica.
      truncate - Truncate the replica.
      append - Append new data to replica.
      Throws:
      IOException
      IRODSException
      Since:
      0.1.0
    • isOpen

      public boolean isOpen()
      Checks if the stream is open.
      Since:
      0.1.0
    • getNativeHandle

      public int getNativeHandle()
      Returns the native handle to the stream.
      Since:
      0.1.0
    • getReplicaNumber

      public long getReplicaNumber()
      Returns the replica number of the open replica.
      Since:
      0.1.0
    • getReplicaToken

      public String getReplicaToken()
      Returns the replica token associated with the stream.
      Since:
      0.1.0
    • seek

      public void seek(int offset, IRODSDataObjectStream.SeekDirection direction) throws IOException, IRODSException
      Changes the position to write to.
      Parameters:
      offset - The number of bytes to move.
      direction - Describes how the offset is to be interpreted.
      Throws:
      IOException
      IRODSException
      Since:
      0.1.0
    • write

      public void write(int b) throws IOException
      Specified by:
      write in class OutputStream
      Throws:
      IOException
    • flushBuffer

      public void flushBuffer() throws IOException, IRODSException
      Throws:
      IOException
      IRODSException
    • close

      public void close(IRODSDataObjectStream.OnCloseSuccess closeInstructions)
      Closes the stream with additional instructions.

      This option is primarily for use with parallel writes.

      Parameters:
      closeInstructions - Instructions for the server.
      Since:
      0.1.0
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Overrides:
      close in class OutputStream