public class StreamContainer extends DisposableObject implements com.aspose.imaging_internal.interfaces.ISynchronizable
Represents stream container which contains the stream and provides stream processing routines.
Modifier and Type | Field and Description |
---|---|
static int |
READ_WRITE_BYTES_COUNT
Specifies read and write bytes count when reading sequentially.
|
Constructor and Description |
---|
StreamContainer(InputStream stream)
Initializes a new instance of the
StreamContainer class. |
StreamContainer(InputStream stream,
boolean disposeStream)
Initializes a new instance of the
StreamContainer class. |
StreamContainer(com.aspose.ms.System.IO.Stream stream) |
StreamContainer(com.aspose.ms.System.IO.Stream stream,
boolean disposeStream) |
Modifier and Type | Method and Description |
---|---|
boolean |
canRead()
Gets a value indicating whether stream supports reading.
|
boolean |
canSeek()
Gets a value indicating whether stream supports seeking.
|
boolean |
canWrite()
Gets a value indicating whether stream supports writing.
|
void |
flush()
Clears all buffers for this stream and causes any buffered data to be written to the underlying device.
|
long |
getLength()
Gets or sets the stream length in bytes.
|
long |
getPosition()
Gets or sets the current position within the stream.
|
InputStream |
getStream()
Gets the data stream.
|
Object |
getSyncRoot()
Gets an object that can be used to synchronize access to the synchronized resource.
|
boolean |
isStreamDisposedOnClose()
Gets a value indicating whether this stream is disposed on close.
|
int |
read(byte[] bytes)
Reads bytes to fill the specified bytes buffer.
|
int |
read(byte[] buffer,
int offset,
int count)
Reads a sequence of bytes from the current stream and advances the position within the stream by the number of bytes read.
|
int |
readByte()
Reads a byte from the stream and advances the position within the stream by one byte, or returns -1 if at the end of the stream.
|
void |
save(OutputStream destinationStream)
Saves (copies) the stream's data to the specified stream.
|
void |
save(OutputStream destinationStream,
int bufferSize)
Saves (copies) all the stream's data to the specified stream.
|
void |
save(OutputStream destinationStream,
int bufferSize,
long length)
Saves (copies) the stream's data to the specified stream.
|
void |
save(String filePath)
Saves (copies) the stream's data to the specified stream.
|
void |
save(String filePath,
int bufferSize)
Saves (copies) the stream's data to the specified stream.
|
void |
save(String filePath,
int bufferSize,
long length)
Saves (copies) the stream's data to the specified stream.
|
long |
seek(long offset,
int origin)
Sets the position within the current stream.
|
void |
seekBegin()
Sets the stream position to the beginning of the stream.
|
void |
setLength(long value)
Gets or sets the stream length in bytes.
|
void |
setPosition(long value)
Gets or sets the current position within the stream.
|
static com.aspose.ms.System.IO.Stream |
to_Stream(StreamContainer streamContainer)
Performs an explicit conversion from
com.aspose.imaging.StreamContainer to System.IO.Stream . |
byte[] |
toBytes()
Converts the stream data to the
byte array. |
byte[] |
toBytes(long position,
long bytesCount)
Converts the stream data to the
byte array. |
void |
write(byte[] bytes)
Writes all of the specified bytes to the stream.
|
void |
write(byte[] buffer,
int offset,
int count)
Writes a sequence of bytes to the current stream and advances the current position within this stream by the number of bytes written.
|
void |
writeByte(byte value)
Writes a byte to the current position in the stream and advances the position within the stream by one byte.
|
void |
writeTo(StreamContainer streamContainer)
Copies the contained data to another
StreamContainer . |
void |
writeTo(StreamContainer streamContainer,
long length)
Copies the contained data to another
StreamContainer . |
close, dispose, getDisposed
public static final int READ_WRITE_BYTES_COUNT
Specifies read and write bytes count when reading sequentially.
public StreamContainer(InputStream stream)
Initializes a new instance of the StreamContainer
class.
stream
- The stream.public StreamContainer(com.aspose.ms.System.IO.Stream stream)
public StreamContainer(InputStream stream, boolean disposeStream)
Initializes a new instance of the StreamContainer
class.
stream
- The data stream.disposeStream
- if set to true
the stream will be disposed when container is disposed.public StreamContainer(com.aspose.ms.System.IO.Stream stream, boolean disposeStream)
public static com.aspose.ms.System.IO.Stream to_Stream(StreamContainer streamContainer)
Performs an explicit conversion from com.aspose.imaging.StreamContainer
to System.IO.Stream
.
streamContainer
- The stream container.public Object getSyncRoot()
Gets an object that can be used to synchronize access to the synchronized resource.
Value: The object that can be used to synchronize access to the synchronized resource.getSyncRoot
in interface com.aspose.imaging_internal.interfaces.ISynchronizable
public long getPosition()
Gets or sets the current position within the stream. This value represents offset from the starting stream position passed in the StreamContainer constructor.
Value: The current stream position.public void setPosition(long value)
Gets or sets the current position within the stream. This value represents offset from the starting stream position passed in the StreamContainer constructor.
Value: The current stream position.public InputStream getStream()
Gets the data stream.
Value: The data stream.public boolean isStreamDisposedOnClose()
Gets a value indicating whether this stream is disposed on close.
Value:true
if stream is disposed on close; otherwise, false
.public long getLength()
Gets or sets the stream length in bytes. This value is less than the System.IO.Stream.Length
by the starting stream position passed in the StreamContainer constructor.
public void setLength(long value)
Gets or sets the stream length in bytes. This value is less than the System.IO.Stream.Length
by the starting stream position passed in the StreamContainer constructor.
public boolean canRead()
Gets a value indicating whether stream supports reading.
Value:true
if stream supports reading; otherwise, false
.public boolean canSeek()
Gets a value indicating whether stream supports seeking.
Value:true
if stream supports seeking; otherwise, false
.public boolean canWrite()
Gets a value indicating whether stream supports writing.
Value:true
if stream supports writing; otherwise, false
.public void flush()
Clears all buffers for this stream and causes any buffered data to be written to the underlying device.
public void write(byte[] bytes)
Writes all of the specified bytes to the stream.
bytes
- The bytes to write.public void writeByte(byte value)
Writes a byte to the current position in the stream and advances the position within the stream by one byte.
value
- The byte to write to the stream.public int read(byte[] bytes)
Reads bytes to fill the specified bytes buffer.
bytes
- The bytes to fill.public byte[] toBytes()
Converts the stream data to the byte
array.
byte
array.public byte[] toBytes(long position, long bytesCount)
Converts the stream data to the byte
array.
position
- The position to start reading bytes from.bytesCount
- The bytes count to read.byte
array.public int read(byte[] buffer, int offset, int count)
Reads a sequence of bytes from the current stream and advances the position within the stream by the number of bytes read.
buffer
- An array of bytes. When this method returns, the buffer contains the specified byte array with the values between offset
and (offset
+ count
- 1) replaced by the bytes read from the current source.offset
- The zero-based byte offset in buffer
at which to begin storing the data read from the current stream.count
- The maximum number of bytes to be read from the current stream.public int readByte()
Reads a byte from the stream and advances the position within the stream by one byte, or returns -1 if at the end of the stream.
public long seek(long offset, int origin)
Sets the position within the current stream.
offset
- A byte offset relative to the origin
parameter. This value represents offset from the starting stream position passed in the StreamContainer constructor.origin
- A value of type System.IO.SeekOrigin
indicating the reference point used to obtain the new position.public void seekBegin()
Sets the stream position to the beginning of the stream. This value represents offset from the starting stream position passed in the StreamContainer constructor.
public void write(byte[] buffer, int offset, int count)
Writes a sequence of bytes to the current stream and advances the current position within this stream by the number of bytes written.
buffer
- An array of bytes. This method copies count
bytes from buffer
to the current stream.offset
- The zero-based byte offset in buffer
at which to begin copying bytes to the current stream.count
- The number of bytes to be written to the current stream.public void save(OutputStream destinationStream)
Saves (copies) the stream's data to the specified stream. Uses default buffer size ReadWriteBytesCount
and stream Length
value.
destinationStream
- The stream to save the data to.public void save(OutputStream destinationStream, int bufferSize)
Saves (copies) all the stream's data to the specified stream. Uses stream Length
value.
destinationStream
- The stream to save the data to.bufferSize
- The buffer.public void save(OutputStream destinationStream, int bufferSize, long length)
Saves (copies) the stream's data to the specified stream.
destinationStream
- The stream to save the data to.bufferSize
- The buffer size. By default ReadWriteBytesCount
value is used.length
- The stream data length to copy. By default the length is set to Length
value.public void save(String filePath)
Saves (copies) the stream's data to the specified stream. Uses default buffer size ReadWriteBytesCount
and stream Length
value.
filePath
- The file path to save the stream data to.public void save(String filePath, int bufferSize)
Saves (copies) the stream's data to the specified stream. Uses stream Length
value.
filePath
- The file path to save the stream data to.bufferSize
- The buffer size. By default ReadWriteBytesCount
value is used.public void save(String filePath, int bufferSize, long length)
Saves (copies) the stream's data to the specified stream.
filePath
- The file path to save the stream data to.bufferSize
- The buffer size. By default ReadWriteBytesCount
value is used.length
- The stream data length to copy. By default the length is set to Length
value.public void writeTo(StreamContainer streamContainer)
Copies the contained data to another StreamContainer
.
streamContainer
- The stream container to copy to.public void writeTo(StreamContainer streamContainer, long length)
Copies the contained data to another StreamContainer
.
streamContainer
- The stream container to copy to.length
- The bytes count to write.FrameworkException
- Copy operation cannot complete. Cannot read + count + bytes.