Java Utililty Methods Base Encode

List of utility methods to do Base Encode

Description

The list of methods to do Base Encode are organized into topic(s).

Method

StringtoBase2SuffixedString(long n)
to Base Suffixed String
if (n > 0 && Long.bitCount(n) == 1) {
    int i = Long.numberOfTrailingZeros(Math.abs(n)) / 10;
    return (n >> (i * 10)) + BASE_2_SUFFIXES[i];
} else {
    int i = (63 - Long.numberOfLeadingZeros(n)) / 10;
    long factor = 1L << (i * 10);
    long leading = n / factor;
    long decimalFactor = factor / 10;
...
chartoBase32Char(int i)
to Base Char
return BASE32_CHAR_FROM_INT[i];
StringtoBase36(int decimalNumber)
to Base
return fromDecimalToOtherBase(36, decimalNumber);
StringtoBase36(long l)
to Base
return Long.toString(l, 36);
StringtoBase36(long num)
Convert number to base 36 (0-9A-Z)
return toBase(num, BASE36_CHARS);
StringtoBase62(int decimalNumber)
to Base
return fromDecimalToOtherBase(62, decimalNumber);
StringtoBase8(int decimalNumber)
to Base
return fromDecimalToOtherBase(8, decimalNumber);
StringtoBase85String(byte[] data)
to Base String
StringBuffer buffer = new StringBuffer();
int count = 0;
for (int i = 0; i <= data.length - 4; i += 4) {
    char[] base85String = toBase85String(getUnsignedInt(data, i));
    buffer.append(base85String);
    count += base85String.length;
    if (count > 80) {
        buffer.append('\n');
...
StringtoBase90(int i)
to Base
int tmp = i;
StringBuilder result = new StringBuilder();
do {
    int y = tmp % 90;
    result.insert(0, base90[y]);
    tmp = (tmp - y) / 90;
} while (tmp >= 90);
result.insert(0, base90[tmp]);
...