Here you can find the source of formatRowKey(final long number, final int digits, byte[] dest)
public static void formatRowKey(final long number, final int digits, byte[] dest)
//package com.java2s; /*/*from ww w . j a v a 2 s. co m*/ * Copyright (C) 2007-2015 Hypertable, Inc. * * This file is part of Hypertable. * * Hypertable 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 3 * of the License, or any later version. * * Hypertable 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 this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA * 02110-1301, USA. */ public class Main { public static String formatRowKey(final long number, final int digits) { StringBuilder str = new StringBuilder(digits + 1); long d = Math.abs(number); str.setLength(digits); for (int ii = digits - 1; ii >= 0; ii--) { str.setCharAt(ii, (char) ((d % 10) + '0')); d /= 10; } return str.toString(); } public static void formatRowKey(final long number, final int digits, byte[] dest) { long d = Math.abs(number); for (int ii = digits - 1; ii >= 0; ii--) { dest[ii] = (byte) ((d % 10) + '0'); d /= 10; } } }