Java Base64 Encode toBase64(int x)

Here you can find the source of toBase64(int x)

Description

to Base

License

Open Source License

Declaration

public static String toBase64(int x) 

Method Source Code

//package com.java2s;
/*/*  www .  j  a v a  2 s  .com*/
 * jIRCd - Java Internet Relay Chat Daemon
 * Copyright 2003 Tyrel L. Haveman <tyrel@haveman.net>
 *
 * This file is part of jIRCd.
 *
 * jIRCd 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.
 *
 * jIRCd 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 jIRCd; if not, write to the Free Software Foundation, Inc.,
 * 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 */

public class Main {
    private static final char[] encodeLookup = new char[] { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K',
            'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f',
            'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '0',
            '1', '2', '3', '4', '5', '6', '7', '8', '9', '[', ']' };

    public static String toBase64(int x) {
        char[] b64 = new char[6];
        b64[5] = encodeLookup[x & 63];
        x >>>= 6;
        b64[4] = encodeLookup[x & 63];
        x >>>= 6;
        b64[3] = encodeLookup[x & 63];
        x >>>= 6;
        b64[2] = encodeLookup[x & 63];
        x >>>= 6;
        b64[1] = encodeLookup[x & 63];
        x >>>= 6;
        b64[0] = encodeLookup[x & 63];
        return new String(b64);
    }
}

Related

  1. toBase64(byte[] data)
  2. toBase64(byte[] data)
  3. toBase64(final byte[] bytes)
  4. toBase64(final byte[] value)
  5. toBase64(final String str)
  6. toBase64(long num)
  7. toBase64(long value)
  8. toBase64(String value)
  9. toBase64Impl(byte[] data)