Here you can find the source of longToString(long value)
private static String longToString(long value)
//package com.java2s; /**/*from ww w.j a v a2s . c o m*/ * Copyright (c) 2015 SDL Group * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ public class Main { private static final int LONG_ENC_STR_LEN = 11; private static final Character[] printableChars = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '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' }; private static String longToString(long value) { StringBuilder sb = new StringBuilder(); for (int i = 0; i < LONG_ENC_STR_LEN; i++) { int remainder = (int) (value % printableChars.length); sb.insert(0, printableChars[Math.abs(remainder)]); value = value / printableChars.length; if ((i == 0) && (value < 0)) { value = value * 2; } } return sb.toString(); } }