Here you can find the source of lPad(String str, int len, char pad)
public static String lPad(String str, int len, char pad)
//package com.java2s; /*/*from w w w .j a v a 2 s.c om*/ * M2M ServiceFOTA ONM version 1.0 * * Copyright ? 2014 kt corp. All rights reserved. * * This is a proprietary software of kt corp, and you may not use this file except in * compliance with license agreement with kt corp. Any redistribution or use of this * software, with or without modification shall be strictly prohibited without prior written * approval of kt corp, and the copyright notice above does not evidence any actual or * intended publication of such software. */ public class Main { public static String lPad(String str, int len, char pad) { return lPad(str, len, pad, false); } public static String lPad(String str, int len, char pad, boolean isTrim) { if (isEmpty(str)) { return null; } if (isTrim) { str = str.trim(); } for (int i = str.length(); i < len; i++) { str = pad + str; } return str; } public static boolean isEmpty(String str) { if (str != null) { str = str.trim(); } return (str == null || str.length() == 0); } public static String trim(String origString, String trimString) { int startPosit = origString.indexOf(trimString); if (startPosit != -1) { int endPosit = trimString.length() + startPosit; return origString.substring(0, startPosit) + origString.substring(endPosit); } return origString; } }