com.oreilly.servlet
类 Base64Decoder

java.lang.Object
  继承者 java.io.InputStream
      继承者 java.io.FilterInputStream
          继承者 com.oreilly.servlet.Base64Decoder
所有已实现的接口:
Closeable

public 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);
 

版本:
1.1, 2002/11/01, added decodeToBytes() to better handle binary data (thanks to Sean Graham), 1.0, 2000/06/11
作者:
Jason Hunter, Copyright © 2000

字段摘要
 
从类 java.io.FilterInputStream 继承的字段
in
 
构造方法摘要
Base64Decoder(InputStream in)
          Constructs a new Base64 decoder that reads input from the given InputStream.
 
方法摘要
static String decode(String encoded)
          Returns the decoded form of the given encoded string, as a String.
static byte[] decodeToBytes(String encoded)
          Returns the decoded form of the given encoded string, as bytes.
static void main(String[] args)
           
 int read()
          Returns the next decoded character from the stream, or -1 if end of stream was reached.
 int read(byte[] buf, 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.
 
从类 java.io.FilterInputStream 继承的方法
available, close, mark, markSupported, read, reset, skip
 
从类 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.

参数:
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.

覆盖:
FilterInputStream 中的 read
返回:
the decoded character, or -1 if the end of the input stream is reached
抛出:
IOException - if an I/O error occurs

read

public int read(byte[] buf,
                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.

覆盖:
FilterInputStream 中的 read
参数:
buf - the buffer into which the data is read
off - the start offset of the data
len - the maximum number of bytes to read
返回:
the actual number of bytes read, or -1 if the end of the input stream is reached
抛出:
IOException - if an I/O error occurs

decode

public static String decode(String encoded)
Returns the decoded form of the given encoded string, as a String. Note that not all binary data can be represented as a String, so this method should only be used for encoded String data. Use decodeToBytes() otherwise.

参数:
encoded - the string to decode
返回:
the decoded form of the encoded string

decodeToBytes

public static byte[] decodeToBytes(String encoded)
Returns the decoded form of the given encoded string, as bytes.

参数:
encoded - the string to decode
返回:
the decoded form of the encoded string

main

public static void main(String[] args)
                 throws Exception
抛出:
Exception


Copyright © 2013. All Rights Reserved.