public static String toCode(long code) {
        String base2 = Long.toBinaryString(code);
        if (base2.isEmpty())
            return "";

        int padAmount = (int) Math.ceil((double) base2.length() / 6);
        base2 = String.format("%" + padAmount * 6 + "s", base2).replace(' ', '0');

        String encoded = "";
        for (int i = 0; i < padAmount; i++)
            encoded += BASE64URL_CHARMAP
                    .charAt(Integer.parseInt(base2.substring(6 * i, 6 * i + 6), 2));

        return encoded;
    }
Converts an Instagram ID to their shortcode system.

@param code The ID to convert. Must be provided as a string if it's larger than the size of
       an integer, which MOST Instagram IDs are!
@return The shortcode.
src/main/java/com/github/instagram4j/instagram4j/utils/IGUtils.java