Here you can find the source of intToStringBuffer(final int param, final int len)
Parameter | Description |
---|---|
param | An integer to convert |
len | The string length |
public static StringBuffer intToStringBuffer(final int param, final int len)
//package com.java2s; /*//from w w w . j av a 2 s. co m * Utility.java * * HomePage : http://www.codeproject.com/csharp/TraceTool.asp * Download : http://sourceforge.net/projects/tracetool/ * See License.txt for license information * * Author : Thierry Parent * Version : 12.3 * * Provide some utility functions */ public class Main { /** * convert an integer to a StringBuffer (left padding). * @param param An integer to convert * @param len The string length * @return a string representation */ public static StringBuffer intToStringBuffer(final int param, final int len) { StringBuffer temp = new StringBuffer(Integer.toString(param)); leftPadding(temp, len, ' '); return temp; } /** * Left Pad Stringbuffer with special char * @param strBuf Target buffer * @param bufLen Buffer length * @param fill Char to fill * @return a padded StringBuffer */ public static StringBuffer leftPadding(final StringBuffer strBuf, final int bufLen, final char fill) { while (strBuf.length() < bufLen) strBuf.insert(0, fill); return strBuf; } }