Here you can find the source of alignLeft(String val, char pad, int width)
public static String alignLeft(String val, char pad, int width)
//package com.java2s; /* ************************************************************************ # # DivConq//w ww. j a v a2 s . c o m # # http://divconq.com/ # # Copyright: # Copyright 2014 eTimeline, LLC. All rights reserved. # # License: # See the license.txt file in the project's top-level directory for details. # # Authors: # * Andy White # ************************************************************************ */ public class Main { public static String alignLeft(String val, char pad, int width) { if (val == null) val = ""; if (val.length() > width) { val = "*" + val.substring(0, width - 1); return val; } while (val.length() < width) val = val + pad; return val; } /** * Gets a CharSequence length or {@code 0} if the CharSequence is * {@code null}. * * @param cs * a CharSequence or {@code null} * @return CharSequence length or {@code 0} if the CharSequence is * {@code null}. * @since 2.4 * @since 3.0 Changed signature from length(String) to length(CharSequence) */ public static int length(final CharSequence cs) { return cs == null ? 0 : cs.length(); } }