Here you can find the source of toCharListNumber(int value, String list)
Parameter | Description |
---|---|
value | the value. Must be >= 1. |
list | the character list to use. Must contain at least 4 characters. |
Parameter | Description |
---|---|
IllegalArgumentException | if the value is < 1 |
public static String toCharListNumber(int value, String list) throws IllegalArgumentException
//package com.java2s; public class Main { /**//from w ww. ja v a 2 s . c om * Create a string which represents the specified value using the specified list of characters. * @param value the value. Must be >= 1. * @param list the character list to use. Must contain at least 4 characters. * @return the formated number * @throws IllegalArgumentException if the value is < 1 */ public static String toCharListNumber(int value, String list) throws IllegalArgumentException { if (value < 1) { throw new IllegalArgumentException("value"); } int pos = 16; char[] tmp = new char[pos]; do { tmp[--pos] = list.charAt(--value % list.length()); value /= list.length(); } while (value > 0); return new String(tmp, pos, tmp.length - pos); } }