java.lang.Object
java.io.OutputStream
java.io.FilterOutputStream
com.aoapps.hodgepodge.io.PaddingOutputStream
- All Implemented Interfaces:
Closeable
,Flushable
,AutoCloseable
Pads the last block with the necessary number of bytes before closing the stream.
If padding is necessary without closing, use
finish
.-
Field Summary
Fields inherited from class java.io.FilterOutputStream
out
-
Constructor Summary
ConstructorsConstructorDescriptionPaddingOutputStream
(OutputStream out, int blockSize) Uses a default instance ofSecureRandom
, which is not a strong instance to avoid blocking, as the source of random bytes for padding.PaddingOutputStream
(OutputStream out, int blockSize, byte padding) Deprecated.Please use random paddingPaddingOutputStream
(OutputStream out, int blockSize, SecureRandom secureRandom) Uses the given source of random bytes for padding.PaddingOutputStream
(OutputStream out, int blockSize, Random random) Deprecated.Please useSecureRandom
. -
Method Summary
Methods inherited from class java.io.FilterOutputStream
flush
Methods inherited from class java.io.OutputStream
nullOutputStream
-
Constructor Details
-
PaddingOutputStream
@Deprecated(forRemoval=false) public PaddingOutputStream(OutputStream out, int blockSize, Random random) Deprecated.Please useSecureRandom
. This method will stay, but will remain deprecated since it should only be used after careful consideration.Uses the given source of random bytes for padding.- Parameters:
blockSize
- When<= 0
, no padding will be performed. This is consistent with zero returned fromCipher.getBlockSize()
when not a block cipher.
-
PaddingOutputStream
Uses the given source of random bytes for padding.- Parameters:
blockSize
- When<= 0
, no padding will be performed. This is consistent with zero returned fromCipher.getBlockSize()
when not a block cipher.
-
PaddingOutputStream
Uses a default instance ofSecureRandom
, which is not a strong instance to avoid blocking, as the source of random bytes for padding.- Parameters:
blockSize
- When<= 0
, no padding will be performed. This is consistent with zero returned fromCipher.getBlockSize()
when not a block cipher.
-
PaddingOutputStream
Deprecated.Please use random padding
-
-
Method Details
-
write
- Overrides:
write
in classFilterOutputStream
- Throws:
IOException
-
write
- Overrides:
write
in classFilterOutputStream
- Throws:
IOException
-
write
- Overrides:
write
in classFilterOutputStream
- Throws:
IOException
-
finish
Pads and flushes without closing the underlying stream.- Throws:
IOException
-
close
Pads, flushes, and closes the underlying stream.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classFilterOutputStream
- Throws:
IOException
-