Java BigInteger to convertToBase62String(BigInteger value)

Here you can find the source of convertToBase62String(BigInteger value)

Description

convert To Base String

License

Open Source License

Declaration

private static String convertToBase62String(BigInteger value) 

Method Source Code


//package com.java2s;
import java.math.BigInteger;

public class Main {
    private static final String[] elements = {

            "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"

    };/*from ww w .j  av  a 2  s . c  o m*/
    private static final BigInteger BASE = new BigInteger("62");

    private static String convertToBase62String(BigInteger value) {
        StringBuilder sb = new StringBuilder();
        while (true) {
            BigInteger mod = value.mod(BASE);
            sb.insert(0, elements[mod.intValue()]);
            value = value.divide(BASE);
            if (value.equals(BigInteger.ZERO)) {
                break;
            }
        }
        return sb.toString();
    }
}

Related

  1. convertBigIntegerIntoInetAddress(final BigInteger i)
  2. convertBigIntegerToNBytes( final BigInteger bigInteger, final int numBytes)
  3. convertPositive(BigInteger bi)
  4. convertRealNumberBits(BigInteger source, int size, int direction)
  5. convertRepresentation(BigInteger b)
  6. convertToLong(BigInteger bigInteger)
  7. convertToString(BigInteger biSequence, int kmerSize)
  8. convertValueToZeroIfNullOrNegative(BigInteger value)
  9. getUnsignedBigIntegerAsHex(BigInteger bi)