de.nava.informa.utils
Class Base64Decoder
java.lang.Object
java.io.InputStream
java.io.FilterInputStream
de.nava.informa.utils.Base64Decoder
- All Implemented Interfaces:
- Closeable
class Base64Decoder
- extends FilterInputStream
A class to decode Base64 streams and strings.
See RFC 1521 section 5.2 for details of the Base64 algorithm.
This class can be used for decoding strings:
String encoded = "d2VibWFzdGVyOnRyeTJndWVTUw";
String decoded = Base64Decoder.decode(encoded);
or for decoding streams:
InputStream in = new Base64Decoder(System.in);
- Version:
- 1.0, 2000/06/11
- Author:
- Jason Hunter, Copyright 2000
Constructor Summary |
Base64Decoder(InputStream in)
Constructs a new Base64 decoder that reads input from the given
InputStream. |
Method Summary |
static String |
decode(String encoded)
Returns the decoded form of the given encoded string. |
int |
read()
Returns the next decoded character from the stream, or -1 if
end of stream was reached. |
int |
read(byte[] b,
int off,
int len)
Reads decoded data into an array of bytes and returns the actual
number of bytes read, or -1 if end of stream was reached. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Base64Decoder
public Base64Decoder(InputStream in)
- Constructs a new Base64 decoder that reads input from the given
InputStream.
- Parameters:
in
- the input stream
read
public int read()
throws IOException
- Returns the next decoded character from the stream, or -1 if
end of stream was reached.
- Overrides:
read
in class FilterInputStream
- Returns:
- the decoded character, or -1 if the end of the
input stream is reached
- Throws:
IOException
- if an I/O error occurs
read
public int read(byte[] b,
int off,
int len)
throws IOException
- Reads decoded data into an array of bytes and returns the actual
number of bytes read, or -1 if end of stream was reached.
- Overrides:
read
in class FilterInputStream
- Parameters:
b
- the buffer into which the data is readoff
- the start offset of the datalen
- the maximum number of bytes to read
- Returns:
- the actual number of bytes read, or -1 if the end of the
input stream is reached
- Throws:
IOException
- if an I/O error occurs
decode
public static String decode(String encoded)
- Returns the decoded form of the given encoded string.
- Parameters:
encoded
- the string to decode
- Returns:
- the decoded form of the encoded string
Copyright © 2002-2007 Niko Schmuck.
All Rights Reserved.