Here you can find the source of leftTrim(StringBuilder pStringBuilder)
Parameter | Description |
---|---|
pStringBuilder | The StringBuffer object to remove leading and trailing whitespace characters from. |
public static StringBuilder leftTrim(StringBuilder pStringBuilder)
//package com.java2s; //License from project: Open Source License public class Main { /**//from ww w. ja v a 2s. co m * Similar to the Perl chomp command. Removes all leading * whitespace. * * @param pStringBuilder The StringBuffer object to remove leading and trailing whitespace * characters from. * @return StringBuffer the chomped string. */ public static StringBuilder leftTrim(StringBuilder pStringBuilder) { while (true) { if (pStringBuilder.length() != 0 && Character.isWhitespace(pStringBuilder.charAt(0))) { pStringBuilder.deleteCharAt(0); } else { break; } } return pStringBuilder; } /** * Similar to the Perl chomp command. Removes all leading * whitespace. * * @param pString The String object to remove leading and trailing whitespace * characters from. * @return String the chomped string. */ public static String leftTrim(String pString) { return leftTrim(new StringBuilder(pString)).toString(); } }