Package org.irods.irods4j.high_level.io
Class IRODSDataObjectOutputStream
java.lang.Object
java.io.OutputStream
org.irods.irods4j.high_level.io.IRODSDataObjectOutputStream
- All Implemented Interfaces:
Closeable,Flushable,AutoCloseable
A buffered output stream that makes it easy to write iRODS data objects.
- Since:
- 0.1.0
-
Constructor Summary
ConstructorsConstructorDescriptionInitializes a new instance with a buffer size of 65536 bytes.IRODSDataObjectOutputStream(int bufferSize) Initializes a new instance with a custom buffer size.IRODSDataObjectOutputStream(IRODSApi.RcComm comm, String logicalPath, boolean truncate, boolean append) Initializes a new instance and opens a data object for writing.IRODSDataObjectOutputStream(IRODSApi.RcComm comm, String logicalPath, long replicaNumber, boolean truncate, boolean append) Initializes a new instance and opens a specific replica for writing.IRODSDataObjectOutputStream(IRODSApi.RcComm comm, String logicalPath, String rootResourceName, boolean truncate, boolean append) Initializes a new instance and opens a replica for writing.IRODSDataObjectOutputStream(IRODSApi.RcComm comm, String replicaToken, String logicalPath, long replicaNumber, boolean truncate, boolean append) Initializes a new instance and opens a specific replica for parallel writing. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()voidclose(IRODSDataObjectStream.OnCloseSuccess closeInstructions) Closes the stream with additional instructions.voidintReturns the native handle to the stream.longReturns the replica number of the open replica.Returns the replica token associated with the stream.booleanisOpen()Checks if the stream is open.voidopen(IRODSApi.RcComm comm, String logicalPath, boolean truncate, boolean append) Opens a data object for writing.voidopen(IRODSApi.RcComm comm, String logicalPath, long replicaNumber, boolean truncate, boolean append) Opens a specific replica for writing.voidopen(IRODSApi.RcComm comm, String logicalPath, String rootResourceName, boolean truncate, boolean append) Opens a replica for writing.voidopen(IRODSApi.RcComm comm, String replicaToken, String logicalPath, long replicaNumber, boolean truncate, boolean append) Opens a specific replica for parallel writing.voidseek(int offset, IRODSDataObjectStream.SeekDirection direction) Changes the position to write to.voidwrite(int b) Methods inherited from class java.io.OutputStream
flush, nullOutputStream, write, write
-
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:
IOExceptionIRODSException- 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:
IOExceptionIRODSException- 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:
IOExceptionIRODSException- 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:
IOExceptionIRODSException- 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:
IOExceptionIRODSException- 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:
IOExceptionIRODSException- 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:
IOExceptionIRODSException- 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:
IOExceptionIRODSException- 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
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:
IOExceptionIRODSException- Since:
- 0.1.0
-
write
- Specified by:
writein classOutputStream- Throws:
IOException
-
flushBuffer
- Throws:
IOExceptionIRODSException
-
close
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:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classOutputStream
-