Package com.alachisoft.ncache.client
Interface CacheStream
-
- All Superinterfaces:
java.lang.AutoCloseable
public interface CacheStream extends java.lang.AutoCloseableCacheStream is derived from java.io.BufferedInputStream and java.io.BufferedOutputStream. It is designed to put/fetch BLOB using the standard CacheStream interface.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description booleancanRead()Gets a value indicating whether the current stream supports reading.booleancanSeek()Gets a value indicating whether the current stream supports seeking.booleancanWrite()Gets a value indicating whether the current stream supports writing.booleanclosed()Gets a value indicating whether stream is closed or not.voidflush()When overridden in a derived class, clears all buffers for this stream and causes any buffered data to be written to the underlying device.java.io.BufferedInputStreamgetBufferedInputStream()Gets theBufferedInputStreaminstance.java.io.BufferedInputStreamgetBufferedInputStream(int bufferSize)Gets theBufferedInputStreamof given buffer size.java.io.BufferedOutputStreamgetBufferedOutputStream()Gets theBufferedOutputStreamof given buffer size.java.io.BufferedOutputStreamgetBufferedOutputStream(int bufferSize)Gets theBufferedOutputStreamof given buffer size.longlength()Gets the length of the stream.longposition()Gets/Sets the position within current stream.intread(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.longseek(long offset)Sets the position within the current stream.voidsetLength(long value)Sets the length of the stream.voidwrite(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.
-
-
-
Method Detail
-
length
long length() throws java.lang.ExceptionGets the length of the stream.- Returns:
- The length of the stream.
- Throws:
java.lang.Exception
-
canRead
boolean canRead()
Gets a value indicating whether the current stream supports reading.- Returns:
- True, if stream supports reading otherwise, false.
-
canSeek
boolean canSeek()
Gets a value indicating whether the current stream supports seeking.- Returns:
- True, if stream supports seeking otherwise, false.
-
canWrite
boolean canWrite()
Gets a value indicating whether the current stream supports writing.- Returns:
- True, if stream supports writing otherwise, false.
-
closed
boolean closed()
Gets a value indicating whether stream is closed or not.- Returns:
- True, if stream is closed otherwise, false.
-
flush
void flush()
When overridden in a derived class, clears all buffers for this stream and causes any buffered data to be written to the underlying device.
-
position
long position() throws java.lang.ExceptionGets/Sets the position within current stream.- Returns:
- The position within the current stream.
- Throws:
java.lang.Exception
-
seek
long seek(long offset) throws NotSupportedException
Sets the position within the current stream.- Parameters:
offset- A byte offset relative to the origin parameter.- Returns:
- Position of the byte(s) within the current stream.
- Throws:
NotSupportedException- If stream does not support seeking.
-
setLength
void setLength(long value) throws NotSupportedExceptionSets the length of the stream.- Parameters:
value- The desired length of the current stream in bytes.- Throws:
NotSupportedException- If stream does not support both writing and seeking.
-
getBufferedInputStream
java.io.BufferedInputStream getBufferedInputStream(int bufferSize) throws java.lang.ExceptionGets theBufferedInputStreamof given buffer size.- Parameters:
bufferSize- Buffer size in bytes.- Returns:
- An instance of java.io.BufferedInputStream.
- Throws:
java.lang.Exception
-
getBufferedInputStream
java.io.BufferedInputStream getBufferedInputStream() throws java.lang.ExceptionGets theBufferedInputStreaminstance.- Returns:
- An instance of java.io.BufferedInputStream.
- Throws:
java.lang.Exception
-
getBufferedOutputStream
java.io.BufferedOutputStream getBufferedOutputStream(int bufferSize) throws java.lang.ExceptionGets theBufferedOutputStreamof given buffer size.- Parameters:
bufferSize- Buffer size in bytes.- Returns:
- An instance of java.io.BufferedOutputStream.
- Throws:
java.lang.Exception
-
getBufferedOutputStream
java.io.BufferedOutputStream getBufferedOutputStream() throws java.lang.ExceptionGets theBufferedOutputStreamof given buffer size.- Returns:
- An instance of java.io.BufferedOutputStream.
- Throws:
java.lang.Exception
-
read
int read(byte[] buffer, int offset, int count) throws java.lang.ExceptionReads a sequence of bytes from the current stream and advances the position within the stream by the number of bytes read.- Parameters:
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 being read from the current stream.count- The maximum number of bytes to be read from the current stream.- Returns:
- 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.
- Throws:
java.lang.Exception
-
write
void write(byte[] buffer, int offset, int count) throws java.lang.ExceptionWrites a sequence of bytes to the current stream and advances the current position within this stream by the number of bytes written.- Parameters:
buffer- An array of bytes. This method copies count bytes from buffer to the current stream.offset- The zero-based byte offset in buffer that determine when to begin copying bytes to the current stream.count- The number of bytes to be written to the current stream.- Throws:
java.lang.Exception
-
-