ariba.util.core
Class Base64

java.lang.Object
  extended by ariba.util.core.Base64

public class Base64
extends java.lang.Object

Base64. Utilities for base 64 decoding rfc-1521: Base64 Alphabet See http://info.internet.isi.edu/in-notes/rfc/files/rfc1521.txt


Field Summary
static java.lang.String ClassName
           
static int LineSize
           
static char PadChar
           
 
Constructor Summary
Base64()
           
 
Method Summary
static byte[] decode(byte[] data, int start, int len)
          This method decodes the given byte[] using the base64-encoding specified in RFC-1521 (Section 5.2).
static java.lang.String decode(java.lang.String string)
          This method decodes the given byte[] using the base64-encoding specified in RFC-1521 (Section 5.2).
static byte[] decodeFromString(java.lang.String string)
          The method you wanted to have all along!
static byte[] encode(byte[] data, int start, int len)
          This method encodes the given byte[] using the base64-encoding specified in RFC-1521 (Section 5.2).
static java.lang.String encode(java.lang.String string)
          This method encodes the given String using the base64-encoding specified in RFC-1521 (Section 5.2).
static void encodeAndSend(java.io.File file, java.io.OutputStream outputStream)
          This method will Base64 encode the contents of a file and output it to a specified OutputStream.
static void encodeAndSend(java.io.InputStream inputStream, java.io.OutputStream outputStream)
           
static java.lang.String encodeToString(byte[] contents)
          The methods you actually wanted ...
static void main(java.lang.String[] args)
          For testing, but not moved to test.ariba.util.core.* because it can be useful for debugging in the field with support.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ClassName

public static final java.lang.String ClassName
See Also:
Constant Field Values

PadChar

public static final char PadChar
See Also:
Constant Field Values

LineSize

public static final int LineSize
See Also:
Constant Field Values
Constructor Detail

Base64

public Base64()
Method Detail

decode

public static java.lang.String decode(java.lang.String string)
This method decodes the given byte[] using the base64-encoding specified in RFC-1521 (Section 5.2). See http://info.internet.isi.edu/in-notes/rfc/files/rfc1521.txt

Parameters:
string - the string to decode.
Returns:
the decoded string or null if there was a problem decoding

decode

public static final byte[] decode(byte[] data,
                                  int start,
                                  int len)
This method decodes the given byte[] using the base64-encoding specified in RFC-1521 (Section 5.2). See http://info.internet.isi.edu/in-notes/rfc/files/rfc1521.txt

Parameters:
data - the base64-encoded data.
start - the position in the array to start.
len - the number of bytes to decode.
Returns:
the decoded data.

encode

public static java.lang.String encode(java.lang.String string)
This method encodes the given String using the base64-encoding specified in RFC-1521 (Section 5.2). Makes no provisions for encoding more than a line's worth of data (i.e. '\n' chars are not inserted into the encode output so you should keep the (len-start) <= 57 bytes. (This results in a maximum of (57/3)*4 or 76 characters per output line.) See http://info.internet.isi.edu/in-notes/rfc/files/rfc1521.txt

Parameters:
string - data to be base64-encoded.
Returns:
the encoded data or null if there was a problem encoding

encode

public static final byte[] encode(byte[] data,
                                  int start,
                                  int len)
This method encodes the given byte[] using the base64-encoding specified in RFC-1521 (Section 5.2). Makes no provisions for encoding more than a line's worth of data (i.e. '\n' chars are not inserted into the encode output so you should keep the (len-start) <= 57 bytes. (This results in a maximum of (57/3)*4 or 76 characters per output line.) See http://info.internet.isi.edu/in-notes/rfc/files/rfc1521.txt

Parameters:
data - data to be base64-encoded.
start - the position in the array to start.
len - the number of bytes to encode.
Returns:
the encoded data.

encodeToString

public static java.lang.String encodeToString(byte[] contents)
The methods you actually wanted ...

Parameters:
contents -
Returns:
base-64 encoded message.

decodeFromString

public static byte[] decodeFromString(java.lang.String string)
The method you wanted to have all along!

Parameters:
string - base-64 encoded string
Returns:
base-64 decoded bytes from the string

encodeAndSend

public static final void encodeAndSend(java.io.File file,
                                       java.io.OutputStream outputStream)
This method will Base64 encode the contents of a file and output it to a specified OutputStream. Closing the outputstream will NOT be handled within this method.


encodeAndSend

public static final void encodeAndSend(java.io.InputStream inputStream,
                                       java.io.OutputStream outputStream)
                                throws java.io.IOException
Throws:
java.io.IOException

main

public static void main(java.lang.String[] args)
For testing, but not moved to test.ariba.util.core.* because it can be useful for debugging in the field with support.



AribaWeb User Interface Development Framework
Copyright © 2000-2014 Ariba, Inc. All Rights Reserved.