Class Base64InputStream
- java.lang.Object
-
- java.io.InputStream
-
- java.io.FilterInputStream
-
- org.jboss.as.process.stdin.Base64InputStream
-
- All Implemented Interfaces:
Closeable,AutoCloseable
public class Base64InputStream extends FilterInputStream
Variant of the Commons Codec project's class of the same name. SeeBase64for an explanation of the rationale for creating the variants in this package.Provides Base64 encoding and decoding in a streaming fashion (unlimited size).
The behaviour of the Base64OutputStream is to ENCODE, whereas the behaviour of the Base64InputStream is to DECODE.
This class implements section 6.8. Base64 Content-Transfer-Encoding from RFC 2045 Multipurpose Internet Mail Extensions (MIME) Part One: Format of Internet Message Bodies by Freed and Borenstein.
Since this class operates directly on byte streams, and not character streams, it is hard-coded to only encode/decode character encodings which are compatible with the lower 127 ASCII chart (ISO-8859-1, Windows-1252, UTF-8, etc).
- See Also:
- RFC 2045
-
-
Field Summary
-
Fields inherited from class java.io.FilterInputStream
in
-
-
Constructor Summary
Constructors Constructor Description Base64InputStream(InputStream in)Creates a Base64InputStream such that all data read is Base64-decoded from the original provided InputStream.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intavailable()voidmark(int readLimit)Marks the current position in this input stream.booleanmarkSupported()intread()Reads onebytefrom this input stream.intread(byte[] b, int offset, int len)Attempts to readlenbytes into the specifiedbarray starting atoffsetfrom this InputStream.voidreset()Repositions this stream to the position at the time the mark method was last called on this input stream.longskip(long n)-
Methods inherited from class java.io.FilterInputStream
close, read
-
Methods inherited from class java.io.InputStream
nullInputStream, readAllBytes, readNBytes, readNBytes, transferTo
-
-
-
-
Constructor Detail
-
Base64InputStream
public Base64InputStream(InputStream in)
Creates a Base64InputStream such that all data read is Base64-decoded from the original provided InputStream.- Parameters:
in- InputStream to wrap.
-
-
Method Detail
-
available
public int available() throws IOException- Overrides:
availablein classFilterInputStream- Returns:
0if theInputStreamhas reachedEOF,1otherwise- Throws:
IOException- Since:
- 1.7
-
mark
public void mark(int readLimit)
Marks the current position in this input stream.The
markmethod ofBaseNCodecInputStreamdoes nothing.- Overrides:
markin classFilterInputStream- Parameters:
readLimit- the maximum limit of bytes that can be read before the mark position becomes invalid.- Since:
- 1.7
-
markSupported
public boolean markSupported()
- Overrides:
markSupportedin classFilterInputStream- Returns:
- always returns
false
-
read
public int read() throws IOExceptionReads onebytefrom this input stream.- Overrides:
readin classFilterInputStream- Returns:
- the byte as an integer in the range 0 to 255. Returns -1 if EOF has been reached.
- Throws:
IOException- if an I/O error occurs.
-
read
public int read(byte[] b, int offset, int len) throws IOExceptionAttempts to readlenbytes into the specifiedbarray starting atoffsetfrom this InputStream.- Overrides:
readin classFilterInputStream- Parameters:
b- destination byte arrayoffset- where to start writing the byteslen- maximum number of bytes to read- Returns:
- number of bytes read
- Throws:
IOException- if an I/O error occurs.NullPointerException- if the byte array parameter is nullIndexOutOfBoundsException- if offset, len or buffer size are invalid
-
reset
public void reset() throws IOExceptionRepositions this stream to the position at the time the mark method was last called on this input stream.The
FilterInputStream.reset()method ofBaseNCodecInputStreamdoes nothing except throw anIOException.- Overrides:
resetin classFilterInputStream- Throws:
IOException- if this method is invoked- Since:
- 1.7
-
skip
public long skip(long n) throws IOException- Overrides:
skipin classFilterInputStream- Throws:
IllegalArgumentException- if the provided skip length is negativeIOException- Since:
- 1.7
-
-