picture.io
Class BWTOutputStream
java.lang.Object
|
+--java.io.OutputStream
|
+--java.io.FilterOutputStream
|
+--picture.io.BWTOutputStream
- public class BWTOutputStream
- extends java.io.FilterOutputStream
Filtering output stream which transforms its data with the
Burrows-Wheeler Transformation. For more information see M.
Burrows and D. J. Wheeler: A Block-sorting Lossless Data
Compression Algorithm.
This implementation transforms a whole array if you feed it via the
write(byte[]) method, otherwise it caches the input until
flush() (or close()) is called and then
transforms the accummulated data. You can write multiple
independent BWT data blocks in order to keep them small, the length
of the block precedes the output and the index is written after it,
so the output is 8 bytes per block (i.e. write(byte[]) or
flush() call) bigger.
Fields inherited from class java.io.FilterOutputStream |
out |
Constructor Summary |
BWTOutputStream(java.io.OutputStream out)
Creates output stream writing to out. |
Method Summary |
void |
close()
Transforms the cached data (via write(int)) and writes it to
the underlying output stream, which is closed, too. |
void |
flush()
Transforms the cached data (via write(int)) and writes it to
the underlying output stream, which is flushed, too. |
static void |
main(java.lang.String[] args)
|
void |
write(byte[] b,
int off,
int len)
Transforms a byte array with BWT and writes it (together with 8
bytes of other data) to the underlying output
stream. |
void |
write(int b)
Writes a byte. |
Methods inherited from class java.io.FilterOutputStream |
write |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
BWTOutputStream
public BWTOutputStream(java.io.OutputStream out)
- Creates output stream writing to out.
write
public void write(int b)
throws java.io.IOException
- Writes a byte. Attention: the byte isn't
written to the underlying output stream until a call of flush()
(or close()). Don't mix it with write(byte[]) without flush(),
othwise the output will be mixed up.
- Overrides:
write
in class java.io.FilterOutputStream
- Parameters:
b
- byte to write- Throws:
java.io.IOException
-
write
public void write(byte[] b,
int off,
int len)
throws java.io.IOException
- Transforms a byte array with BWT and writes it (together with 8
bytes of other data) to the underlying output
stream. Don't mix it with write(int) without flush(),
othwise the output will be mixed up.
- Overrides:
write
in class java.io.FilterOutputStream
- Parameters:
b
- byte array to writeoff
- starting offsetlen
- length of data- Throws:
IOException.
-
flush
public void flush()
throws java.io.IOException
- Transforms the cached data (via write(int)) and writes it to
the underlying output stream, which is flushed, too.
- Overrides:
flush
in class java.io.FilterOutputStream
- Throws:
IOException.
-
close
public void close()
throws java.io.IOException
- Transforms the cached data (via write(int)) and writes it to
the underlying output stream, which is closed, too.
- Overrides:
close
in class java.io.FilterOutputStream
- Throws:
IOException.
-
main
public static void main(java.lang.String[] args)
throws java.io.IOException