com.starteam.util
Class Base64

java.lang.Object
  extended by com.starteam.util.Base64

public final class Base64
extends java.lang.Object

A utility class for encoding and decoding binary data in base64. More information on base64 encoding can be found in RFC 2045 - Multipurpose Internet Mail Extensions (MIME) part one.


Method Summary
static byte[] decode(java.lang.String data)
          Returns the byte array represented by the specified base64 encoded data.
static java.lang.String decodeAsString(java.lang.String data)
          Returns the String decoding of the specified base64 encoded data.
static void decodeToFile(java.lang.String data, java.io.File outFile)
          Decodes the specified base64 encoded data but puts the output in to the specified File.
static void decodeToStream(java.lang.String data, java.io.OutputStream out)
          Decodes the specified base64 encoded data but puts the output in to the specified OutputStream.
static java.lang.String encode(byte[] data)
          Returns a String encoding of the specified data in base64.
static byte[] encodeBytes(byte[] data, int pos, int len)
          Returns a byte array encoding of the specified data in base64.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

encode

public static java.lang.String encode(byte[] data)
Returns a String encoding of the specified data in base64.

Parameters:
data - the data to be encoded
Returns:
the base64 encoding of the specified data

decodeAsString

public static java.lang.String decodeAsString(java.lang.String data)
Returns the String decoding of the specified base64 encoded data. Since decoding really should return a byte array this method simply treats each byte as the corresponding UNICODE character with the high byte set to zero. This is equivalent to treating the decoded bytes as the ISO-8859-1 encoding of the returned string.

Parameters:
data - the base64 encoded data to be decoded
Returns:
the decoded data represented as a String

decode

public static byte[] decode(java.lang.String data)
Returns the byte array represented by the specified base64 encoded data.

Parameters:
data - the base64 data to be decoded
Returns:
the decoded data

decodeToFile

public static void decodeToFile(java.lang.String data,
                                java.io.File outFile)
                         throws java.io.IOException
Decodes the specified base64 encoded data but puts the output in to the specified File.

Parameters:
data - a base64 encoding of some data
outFile - the file to which the decoded data is to be written
Throws:
java.io.IOException

decodeToStream

public static void decodeToStream(java.lang.String data,
                                  java.io.OutputStream out)
                           throws java.io.IOException
Decodes the specified base64 encoded data but puts the output in to the specified OutputStream.

Parameters:
data - a base64 encoding of some data
out - the OutputStream to which the decoded data is to be written
Throws:
java.io.IOException

encodeBytes

public static byte[] encodeBytes(byte[] data,
                                 int pos,
                                 int len)
Returns a byte array encoding of the specified data in base64.

Parameters:
data - the data to be encoded
pos - the starting position of the data to be encoded
len - the length of data to be encoded
Returns:
the base64 encoding of the specified data as a byte array


StarTeam SDK 14.0, Build 21
Copyright © 2003-2012 Borland Software Corporation. All rights reserved.