StreamContainer

Inheritance: java.lang.Object, com.aspose.psd.DisposableObject

All Implemented Interfaces: com.aspose.internal.interfaces.ISynchronizable

public class StreamContainer extends DisposableObject implements ISynchronizable

Represents stream container which contains the stream and provides stream processing routines.

Constructors

ConstructorDescription
StreamContainer(InputStream stream)Initializes a new instance of the StreamContainer class.
StreamContainer(System.IO.Stream stream)
StreamContainer(InputStream stream, boolean disposeStream)Initializes a new instance of the StreamContainer class.
StreamContainer(System.IO.Stream stream, boolean disposeStream)

Fields

FieldDescription
READ_WRITE_BYTES_COUNTSpecifies read and write bytes count when reading sequentially.

Methods

MethodDescription
canRead()Gets a value indicating whether stream supports reading.
canSeek()Gets a value indicating whether stream supports seeking.
canWrite()Gets a value indicating whether stream supports writing.
close()Implements the Closable interface and can be used in the try-with-resources statement since JDK 1.7.
create_internalized(System.IO.Stream stream, long startPosition, boolean disposeStream)
dispose()Disposes the current instance.
equals(Object arg0)
flush()Clears all buffers for this stream and causes any buffered data to be written to the underlying device.
getClass()
getDisposed()Gets a value indicating whether this instance is disposed.
getLength()Gets or sets the stream length in bytes.
getPosition()Gets or sets the current position within the stream.
getStream()Gets the data stream.
getStream_internalized()
getSyncRoot()Gets an object that can be used to synchronize access to the synchronized resource.
hashCode()
isStreamDisposedOnClose()Gets a value indicating whether this stream is disposed on close.
notify()
notifyAll()
read(byte[] bytes)Reads bytes to fill the specified bytes buffer.
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.
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.
save(OutputStream destinationStream)Saves (copies) the stream’s data to the specified stream.
save(OutputStream destinationStream, int bufferSize)Saves (copies) all the stream’s data to the specified stream.
save(OutputStream destinationStream, int bufferSize, long length)Saves (copies) the stream’s data to the specified stream.
save(String filePath)Saves (copies) the stream’s data to the specified stream.
save(String filePath, int bufferSize)Saves (copies) the stream’s data to the specified stream.
save(String filePath, int bufferSize, long length)Saves (copies) the stream’s data to the specified stream.
seek(long offset, int origin)Sets the position within the current stream.
seekBegin()Sets the stream position to the beginning of the stream.
setLength(long value)Gets or sets the stream length in bytes.
setPosition(long value)Gets or sets the current position within the stream.
takeAwayStream_internalized(StreamContainer src)
toBytes()Converts the stream data to the byte array.
toBytes(long position, long bytesCount)Converts the stream data to the byte array.
toString()
to_Stream(StreamContainer streamContainer)Performs an explicit conversion from com.aspose.imaging.StreamContainer to System.IO.Stream .
wait()
wait(long arg0)
wait(long arg0, int arg1)
write(byte[] bytes)Writes all of the specified bytes to the stream.
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.
writeByte(byte value)Writes a byte to the current position in the stream and advances the position within the stream by one byte.
writeTo(StreamContainer streamContainer)Copies the contained data to another StreamContainer .
writeTo(StreamContainer streamContainer, long length)Copies the contained data to another StreamContainer .

StreamContainer(InputStream stream)

public StreamContainer(InputStream stream)

Initializes a new instance of the StreamContainer class.

Parameters:

ParameterTypeDescription
streamjava.io.InputStreamThe stream.

StreamContainer(System.IO.Stream stream)

public StreamContainer(System.IO.Stream stream)

Parameters:

ParameterTypeDescription
streamcom.aspose.ms.System.IO.Stream

StreamContainer(InputStream stream, boolean disposeStream)

public StreamContainer(InputStream stream, boolean disposeStream)

Initializes a new instance of the StreamContainer class.

Parameters:

ParameterTypeDescription
streamjava.io.InputStreamThe data stream.
disposeStreambooleanif set to true the stream will be disposed when container is disposed.

StreamContainer(System.IO.Stream stream, boolean disposeStream)

public StreamContainer(System.IO.Stream stream, boolean disposeStream)

Parameters:

ParameterTypeDescription
streamcom.aspose.ms.System.IO.Stream
disposeStreamboolean

READ_WRITE_BYTES_COUNT

public static final int READ_WRITE_BYTES_COUNT

Specifies read and write bytes count when reading sequentially.

canRead()

public boolean canRead()

Gets a value indicating whether stream supports reading.

Value: true if stream supports reading; otherwise, false .

Returns: boolean

canSeek()

public boolean canSeek()

Gets a value indicating whether stream supports seeking.

Value: true if stream supports seeking; otherwise, false .

Returns: boolean

canWrite()

public boolean canWrite()

Gets a value indicating whether stream supports writing.

Value: true if stream supports writing; otherwise, false .

Returns: boolean

close()

public void close()

Implements the Closable interface and can be used in the try-with-resources statement since JDK 1.7. This method simply call dispose method.

create_internalized(System.IO.Stream stream, long startPosition, boolean disposeStream)

public static StreamContainer create_internalized(System.IO.Stream stream, long startPosition, boolean disposeStream)

Parameters:

ParameterTypeDescription
streamcom.aspose.ms.System.IO.Stream
startPositionlong
disposeStreamboolean

Returns: StreamContainer

dispose()

public final void dispose()

Disposes the current instance.

equals(Object arg0)

public boolean equals(Object arg0)

Parameters:

ParameterTypeDescription
arg0java.lang.Object

Returns: boolean

flush()

public void flush()

Clears all buffers for this stream and causes any buffered data to be written to the underlying device.

getClass()

public final native Class<?> getClass()

Returns: java.lang.Class

getDisposed()

public final boolean getDisposed()

Gets a value indicating whether this instance is disposed.

Returns: boolean - true if disposed; otherwise, false .

getLength()

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.

Value: The stream length.

Returns: long

getPosition()

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.

Returns: long

getStream()

public InputStream getStream()

Gets the data stream.

Value: The data stream.

Returns: java.io.InputStream

getStream_internalized()

public System.IO.Stream getStream_internalized()

Returns: com.aspose.ms.System.IO.Stream

getSyncRoot()

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.

Returns: java.lang.Object

hashCode()

public native int hashCode()

Returns: int

isStreamDisposedOnClose()

public boolean isStreamDisposedOnClose()

Gets a value indicating whether this stream is disposed on close.

Value: true if stream is disposed on close; otherwise, false .

Returns: boolean

notify()

public final native void notify()

notifyAll()

public final native void notifyAll()

read(byte[] bytes)

public int read(byte[] bytes)

Reads bytes to fill the specified bytes buffer.

Parameters:

ParameterTypeDescription
bytesbyte[]The bytes to fill.

Returns: int - The number of bytes read. This value can be less than the number of bytes in the buffer if there is not enough bytes in the stream.

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

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.

Parameters:

ParameterTypeDescription
bufferbyte[]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.
offsetintThe zero-based byte offset in buffer at which to begin storing the data read from the current stream.
countintThe maximum number of bytes to be read from the current stream.

Returns: int - The total number of bytes read into the buffer. This can be less than the number of bytes requested if that many bytes are not currently available, or zero (0) if the end of the stream has been reached.

readByte()

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.

Returns: int - The unsigned byte cast to an Int32, or -1 if at the end of the stream.

save(OutputStream destinationStream)

public void save(OutputStream destinationStream)

Saves (copies) the stream’s data to the specified stream. Uses default buffer size ReadWriteBytesCount and stream Length value.

Parameters:

ParameterTypeDescription
destinationStreamjava.io.OutputStreamThe stream to save the data to.

save(OutputStream destinationStream, int bufferSize)

public void save(OutputStream destinationStream, int bufferSize)

Saves (copies) all the stream’s data to the specified stream. Uses stream Length value.

Parameters:

ParameterTypeDescription
destinationStreamjava.io.OutputStreamThe stream to save the data to.
bufferSizeintThe buffer.

save(OutputStream destinationStream, int bufferSize, long length)

public void save(OutputStream destinationStream, int bufferSize, long length)

Saves (copies) the stream’s data to the specified stream.

Parameters:

ParameterTypeDescription
destinationStreamjava.io.OutputStreamThe stream to save the data to.
bufferSizeintThe buffer size. By default ReadWriteBytesCount value is used.
lengthlongThe stream data length to copy. By default the length is set to Length value.

save(String filePath)

public void save(String filePath)

Saves (copies) the stream’s data to the specified stream. Uses default buffer size ReadWriteBytesCount and stream Length value.

Parameters:

ParameterTypeDescription
filePathjava.lang.StringThe file path to save the stream data to.

save(String filePath, int bufferSize)

public void save(String filePath, int bufferSize)

Saves (copies) the stream’s data to the specified stream. Uses stream Length value.

Parameters:

ParameterTypeDescription
filePathjava.lang.StringThe file path to save the stream data to.
bufferSizeintThe buffer size. By default ReadWriteBytesCount value is used.

save(String filePath, int bufferSize, long length)

public void save(String filePath, int bufferSize, long length)

Saves (copies) the stream’s data to the specified stream.

Parameters:

ParameterTypeDescription
filePathjava.lang.StringThe file path to save the stream data to.
bufferSizeintThe buffer size. By default ReadWriteBytesCount value is used.
lengthlongThe stream data length to copy. By default the length is set to Length value.

seek(long offset, int origin)

public long seek(long offset, int origin)

Sets the position within the current stream.

Parameters:

ParameterTypeDescription
offsetlongA byte offset relative to the origin parameter. This value represents offset from the starting stream position passed in the StreamContainer constructor.
originintA value of type System.IO.SeekOrigin indicating the reference point used to obtain the new position.

Returns: long - The new position within the current stream.

seekBegin()

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.

setLength(long value)

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.

Value: The stream length.

Parameters:

ParameterTypeDescription
valuelong

setPosition(long value)

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.

Parameters:

ParameterTypeDescription
valuelong

takeAwayStream_internalized(StreamContainer src)

public static StreamContainer takeAwayStream_internalized(StreamContainer src)

Parameters:

ParameterTypeDescription
srcStreamContainer

Returns: StreamContainer

toBytes()

public byte[] toBytes()

Converts the stream data to the byte array.

Returns: byte[] - The stream data converted to the byte array.

toBytes(long position, long bytesCount)

public byte[] toBytes(long position, long bytesCount)

Converts the stream data to the byte array.

Parameters:

ParameterTypeDescription
positionlongThe position to start reading bytes from.
bytesCountlongThe bytes count to read.

Returns: byte[] - The stream data converted to the byte array.

toString()

public String toString()

Returns: java.lang.String

to_Stream(StreamContainer streamContainer)

public static System.IO.Stream to_Stream(StreamContainer streamContainer)

Performs an explicit conversion from com.aspose.imaging.StreamContainer to System.IO.Stream .

Parameters:

ParameterTypeDescription
streamContainerStreamContainerThe stream container.

Returns: com.aspose.ms.System.IO.Stream - The result of the conversion.

wait()

public final void wait()

wait(long arg0)

public final void wait(long arg0)

Parameters:

ParameterTypeDescription
arg0long

wait(long arg0, int arg1)

public final void wait(long arg0, int arg1)

Parameters:

ParameterTypeDescription
arg0long
arg1int

write(byte[] bytes)

public void write(byte[] bytes)

Writes all of the specified bytes to the stream.

Parameters:

ParameterTypeDescription
bytesbyte[]The bytes to write.

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

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.

Parameters:

ParameterTypeDescription
bufferbyte[]An array of bytes. This method copies count bytes from buffer to the current stream.
offsetintThe zero-based byte offset in buffer at which to begin copying bytes to the current stream.
countintThe number of bytes to be written to the current stream.

writeByte(byte value)

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.

Parameters:

ParameterTypeDescription
valuebyteThe byte to write to the stream.

writeTo(StreamContainer streamContainer)

public void writeTo(StreamContainer streamContainer)

Copies the contained data to another StreamContainer .

Parameters:

ParameterTypeDescription
streamContainerStreamContainerThe stream container to copy to.

writeTo(StreamContainer streamContainer, long length)

public void writeTo(StreamContainer streamContainer, long length)

Copies the contained data to another StreamContainer .

Parameters:

ParameterTypeDescription
streamContainerStreamContainerThe stream container to copy to.
lengthlongThe bytes count to write.