gnu.java.util

Class Base64


public final class Base64
extends Object

Method Summary

static byte[]
decode(String b64)
Decode a Base-64 string into a byte array.
static String
encode(byte[] buf)
Base64 encode a byte array, with no line wrapping.
static String
encode(byte[] buf, int tw)
Base64 encode a byte array, returning the returning string.
static String
encode(byte[] buf, int offset, int length, int tw)
Base64 encode a byte array, returning the returning string.

Methods inherited from class java.lang.Object

clone, equals, extends Object> getClass, finalize, hashCode, notify, notifyAll, toString, wait, wait, wait

Method Details

decode

public static byte[] decode(String b64)
            throws IOException
Decode a Base-64 string into a byte array.
Parameters:
b64 - The Base-64 encoded string.
Returns:
The decoded bytes.
Throws:
IOException - If the argument is not a valid Base-64 encoding.

encode

public static String encode(byte[] buf)
Base64 encode a byte array, with no line wrapping.
Parameters:
buf - The byte array to encode.
Returns:
buf encoded in Base64.

encode

public static String encode(byte[] buf,
                            int tw)
Base64 encode a byte array, returning the returning string.
Parameters:
buf - The byte array to encode.
tw - The total length of any line, 0 for unlimited.
Returns:
buf encoded in Base64.

encode

public static String encode(byte[] buf,
                            int offset,
                            int length,
                            int tw)
Base64 encode a byte array, returning the returning string.
Parameters:
buf - The byte array to encode.
offset - The offset in the byte array to start.
length - The number of bytes to encode.
tw - The total length of any line, 0 for unlimited.
Returns:
buf encoded in Base64.

Base64.java -- Base64 encoding and decoding. Copyright (C) 2006, 2007 Free Software Foundation, Inc. This file is a part of GNU Classpath. GNU Classpath is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. GNU Classpath is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GNU Classpath; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Linking this library statically or dynamically with other modules is making a combined work based on this library. Thus, the terms and conditions of the GNU General Public License cover the whole combination. As a special exception, the copyright holders of this library give you permission to link this library with independent modules to produce an executable, regardless of the license terms of these independent modules, and to copy and distribute the resulting executable under terms of your choice, provided that you also meet, for each linked independent module, the terms and conditions of the license of that module. An independent module is a module which is not derived from or based on this library. If you modify this library, you may extend this exception to your version of the library, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version. -- Base64 encoding derived from ISC's DHCP. Copyright notices from DHCP follow. See http://www.isc.org/products/DHCP/. Copyright (c) 1996 by Internet Software Consortium. Permission to use, copy, modify, and distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -- Portions Copyright (c) 1995 by International Business Machines, Inc. International Business Machines, Inc. (hereinafter called IBM) grants permission under its copyrights to use, copy, modify, and distribute this Software with or without fee, provided that the above copyright notice and all paragraphs of this notice appear in all copies, and that the name of IBM not be used in connection with the marketing of any product incorporating the Software or modifications thereof, without specific, written prior permission. To the extent it has a right to do so, IBM grants an immunity from suit under its patents, if any, for the use, sale or manufacture of products to the extent that such products are used for performing Domain Name System dynamic updates in TCP/IP networks by means of the Software. No immunity is granted for any product per se or for any other function of any product. THE SOFTWARE IS PROVIDED "AS IS", AND IBM DISCLAIMS ALL WARRANTIES, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL IBM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE, EVEN IF IBM IS APPRISED OF THE POSSIBILITY OF SUCH DAMAGES.