|
Terrier IR Platform 2.2.1 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.io.OutputStream uk.ac.gla.terrier.compression.MemoryOutputStream
public class MemoryOutputStream
This class extends an ordinary OutputStream to handle transparently writes in memory. This means that this class doesn't flush to disk anything, that should be done separately (@see MSBOStream). It allocates a byte[] array of original size, that can grow and be reallocated dynamically if it is needed. The class used for handling the reallocations is @see ArrayUtils.
Field Summary | |
---|---|
static int |
DEFAULT_BUFFER_SIZE
The default size of the internal buffer in bytes |
Constructor Summary | |
---|---|
MemoryOutputStream()
Default constructor. |
|
MemoryOutputStream(int bufferSize)
Creates a new instance of this class setting the buffer size. |
|
MemoryOutputStream(int bufferSize,
int enlargeSize)
Creates a new instance of this class setting the buffer size and the growing ratio |
Method Summary | |
---|---|
void |
close()
Empty method |
void |
flush()
Empty method |
byte[] |
getBuffer()
|
int |
getPos()
|
java.lang.String |
toString()
Writes the sequence of bytes in the byte[] into String format |
void |
write(byte[] b,
int offset,
int length)
Writes a sequence of bytes to the buffer. |
void |
write(int b)
Writes a byte into the buffer. |
void |
writeByte(byte b)
Writes a byte into the buffer. |
Methods inherited from class java.io.OutputStream |
---|
write |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final int DEFAULT_BUFFER_SIZE
Constructor Detail |
---|
public MemoryOutputStream()
public MemoryOutputStream(int bufferSize)
bufferSize
- size of the buffer (in bytes)public MemoryOutputStream(int bufferSize, int enlargeSize)
bufferSize
- size of the buffer (in bytes)enlargeSize
- size the buffer is going to grow if needed (argument to ByteArrays)Method Detail |
---|
public int getPos()
public void write(int b) throws java.io.IOException
write
in class java.io.OutputStream
b
- int containing the byte to write.
java.io.IOException
- if an I/O error occurs.public void writeByte(byte b) throws java.io.IOException
b
- byte to write.
java.io.IOException
- if an I/O error occurs.public void write(byte[] b, int offset, int length) throws java.io.IOException
write
in class java.io.OutputStream
b
- byte[] array containing the bytes to writeoffset
- int offset where the data to write beginslength
- int number of elements to write
java.io.IOException
- if an I/O error occurspublic byte[] getBuffer()
public void flush() throws java.io.IOException
flush
in interface java.io.Flushable
flush
in class java.io.OutputStream
java.io.IOException
public void close() throws java.io.IOException
close
in interface java.io.Closeable
close
in class java.io.OutputStream
java.io.IOException
public java.lang.String toString()
toString
in class java.lang.Object
|
Terrier IR Platform 2.2.1 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |