Package google.registry.util
Class ImprovedInputStream
java.lang.Object
java.io.InputStream
java.io.FilterInputStream
google.registry.util.ImprovedInputStream
- All Implemented Interfaces:
Closeable
,AutoCloseable
InputStream
wrapper that offers some additional magic.
- Byte counting
- Log byte count on close
- Check expected byte count when closed (Optional)
- Close original
InputStream
when closed (Optional) - Overridable
onClose()
method - Throws
NullPointerException
if read afterclose()
- See Also:
-
Field Summary
Fields inherited from class java.io.FilterInputStream
in
-
Constructor Summary
ConstructorDescriptionImprovedInputStream
(String name, InputStream out) ImprovedInputStream
(String name, InputStream in, boolean shouldClose) -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Logs byte count, checks byte count (optional), closes (optional), and self-sabotages.void
mark
(int readlimit) protected void
onClose()
Overridable method that's called byclose()
.int
read()
final int
read
(byte[] b) int
read
(byte[] b, int off, int len) void
reset()
long
skip
(long n) Methods inherited from class java.io.FilterInputStream
available, markSupported
Methods inherited from class java.io.InputStream
nullInputStream, readAllBytes, readNBytes, readNBytes, skipNBytes, transferTo
-
Constructor Details
-
ImprovedInputStream
-
ImprovedInputStream
-
-
Method Details
-
read
- Overrides:
read
in classFilterInputStream
- Throws:
IOException
-
read
- Overrides:
read
in classFilterInputStream
- Throws:
IOException
-
read
- Overrides:
read
in classFilterInputStream
- Throws:
IOException
-
skip
- Overrides:
skip
in classFilterInputStream
- Throws:
IOException
-
mark
public void mark(int readlimit) - Overrides:
mark
in classFilterInputStream
-
reset
- Overrides:
reset
in classFilterInputStream
- Throws:
IOException
-
close
Logs byte count, checks byte count (optional), closes (optional), and self-sabotages.This method may not be overridden, use
onClose()
instead.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classFilterInputStream
- Throws:
IOException
- See Also:
-
onClose
Overridable method that's called byclose()
.This method does nothing by default.
- Throws:
IOException
-