Java Base64 Decode base64Decode(String str)

Here you can find the source of base64Decode(String str)

Description

Decodes the given string using the base64-encoding specified in RFC-2045 (Section 6.8).

License

Open Source License

Parameter

Parameter Description
str the base64-encoded string.

Return

the decoded str.

Declaration

public final static String base64Decode(String str) 

Method Source Code

//package com.java2s;
/*/*from  w  w w. ja va2  s  . co m*/
 WXCodecUtilities.java
 [WOExamplesHarness Project]

 ? Copyright 2001-2007 Apple Inc. All rights reserved.



 In consideration of your agreement to abide by the following terms, and subject to these terms, Apple grants you a personal, non-exclusive license, under Apple?s copyrights in this original Apple software (the ?Apple Software?), to use, reproduce, modify and redistribute the Apple Software, with or without modifications, in source and/or binary forms; provided that if you redistribute the Apple Software in its entirety and without modifications, you must retain this notice and the following text and disclaimers in all such redistributions of the Apple Software.  Neither the name, trademarks, service marks or logos of Apple Computer, Inc. may be used to endorse or promote products derived from the Apple Software without specific prior written permission from Apple.  Except as expressly stated in this notice, no other rights or licenses, express or implied, are granted by Apple herein, including but not limited to any patent rights that may be infringed by your derivative works or by other works in which the Apple Software may be incorporated.

 The Apple Software is provided by Apple on an "AS IS" basis.  APPLE MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.

 IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN  ADVISED OF THE POSSIBILITY OF
 SUCH DAMAGE.
 */

import java.io.ByteArrayInputStream;

public class Main {
    /**
     * Decodes the given string using the base64-encoding
     * specified in RFC-2045 (Section 6.8).
     *
     * @param  str the base64-encoded string.
     * @return the decoded <var>str</var>.
     */
    public final static String base64Decode(String str) {
        if (str == null)
            return null;

        //byte data[] = new byte[str.length()];
        //str.getBytes(0, str.length(), data, 0);
        sun.misc.BASE64Decoder dec = new sun.misc.BASE64Decoder();
        String decodedString = null;
        try {
            decodedString = new String(
                    dec.decodeBuffer(new ByteArrayInputStream(str
                            .getBytes())));
        } catch (java.io.IOException e) {
            e.printStackTrace();
        }
        return decodedString;
    }
}

Related

  1. base64Decode(String input)
  2. base64Decode(String s)
  3. base64Decode(String s)
  4. base64Decode(String s)
  5. base64decode(String s)
  6. base64Decode(String str)
  7. Base64Decode(String str)
  8. base64Decode(String str)
  9. base64decode(String str)