Here you can find the source of longToCharArray(long seat, int length)
public static char[] longToCharArray(long seat, int length)
//package com.java2s; //License from project: Apache License public class Main { /**/*from www. j av a 2s .c o m*/ * * change from long to char array * @param seat * @param length * @return char[]: * @throws */ public static char[] longToCharArray(long seat, int length) { String seatString = Long.toBinaryString(seat); int longLength = seatString.length(); StringBuilder sb = new StringBuilder(); for (int i = 0; i < length - longLength; i++) { sb.append('0'); } sb.append(seatString); return sb.toString().toCharArray(); } }