Class EncryptedOutputStream

java.lang.Object
  extended byjava.io.OutputStream
      extended byjava.io.FilterOutputStream
          extended byEncryptedOutputStream

public class EncryptedOutputStream
extends FilterOutputStream


Field Summary
private  int blocksize
           
private  byte[] buf
           
private static boolean DEBUG
           
private static int DEFAULT_BUFFER_SIZE
           
private  int end
           
private  Object key
           
private static int KEY_SIZE
           
private  int pos
           
 
Fields inherited from class java.io.FilterOutputStream
out
 
Constructor Summary
EncryptedOutputStream(OutputStream out)
          Create an EncryptedOutputStream with the default buffer size.
EncryptedOutputStream(OutputStream out, int bufsize)
          Create an EncryptedOutputStream with a given buffer size.
 
Method Summary
 void close()
          Close the stream.
 void flush()
          Flush the buffer.
private  Object readKey()
          Read the key from the keyfile
 void write(byte[] b, int off, int len)
          Writes len bytes from the byte array starting at off
 void write(int b)
          Write a byte.
 void writeEncryptedBlock()
          Write an encrypted block to the output stream.
 
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
 

Field Detail

DEFAULT_BUFFER_SIZE

private static final int DEFAULT_BUFFER_SIZE
See Also:
Constant Field Values

KEY_SIZE

private static final int KEY_SIZE
See Also:
Constant Field Values

DEBUG

private static final boolean DEBUG
See Also:
Constant Field Values

buf

private byte[] buf

pos

private int pos

end

private int end

blocksize

private int blocksize

key

private Object key
Constructor Detail

EncryptedOutputStream

public EncryptedOutputStream(OutputStream out)
                      throws Exception
Create an EncryptedOutputStream with the default buffer size.

Parameters:
out - underlying output stream to encrypt.

EncryptedOutputStream

public EncryptedOutputStream(OutputStream out,
                             int bufsize)
                      throws Exception
Create an EncryptedOutputStream with a given buffer size.

Parameters:
out - underlying output stream to encrypt.
bufsize - the size of the internal buffer
Method Detail

write

public void write(int b)
           throws IOException
Write a byte.

Parameters:
b - byte to write.
Throws:
IOException

write

public void write(byte[] b,
                  int off,
                  int len)
           throws IOException
Writes len bytes from the byte array starting at off

Parameters:
b - the data
off - data offset
len - number of bytes to write
Throws:
IOException

writeEncryptedBlock

public void writeEncryptedBlock()
                         throws IOException
Write an encrypted block to the output stream.

Throws:
IOException

flush

public void flush()
           throws IOException
Flush the buffer.

Throws:
IOException

readKey

private Object readKey()
                throws Exception
Read the key from the keyfile

Returns:
a key object
Throws:
Exception

close

public void close()
           throws IOException
Close the stream. Calls flush() before closing.

Throws:
IOException