Here you can find the source of lpad(String str, String chr, int length)
Description:Pad string to the left
Parameter | Description |
---|---|
original | string to be padded |
string | to pad |
location | of string to pad |
public static String lpad(String str, String chr, int length)
//package com.java2s; /*/*from w w w . j av a2 s . c o m*/ * $RCSfile: LogStringUtil,v $$ * $Revision: 1.0 $ * $Date: 2010-12-09 $ * * Copyright (C) 2011 GyTech, Inc. All rights reserved. * * This software is the proprietary information of GyTech, Inc. * Use is subject to license terms. */ public class Main { /** * <p>Description:Pad string to the left </p> * @param original string to be padded * @param string to pad * @param location of string to pad * @return the new string */ public static String lpad(String str, String chr, int length) { String retVal = str; for (int i = 0; i < length - str.length(); i++) retVal = chr + retVal; return retVal; } }