Here you can find the source of leftTrim(final String input)
Parameter | Description |
---|---|
input | a parameter |
public static final String leftTrim(final String input)
//package com.java2s; //License from project: Open Source License public class Main { /**// w w w .j a v a2 s. c o m * Get a version of a String with all leading whitespace removed. * * @param input * @return String with leading whitespace removed. Returns the original * reference, if there is no leading whitespace. */ public static final String leftTrim(final String input) { if (input == null) { return null; } final int len = input.length(); int beginIndex = 0; for (int i = 0; i < len; i++) { if (Character.isWhitespace(input.charAt(i))) { ++beginIndex; } else { break; } } if (beginIndex > 0) { if (beginIndex >= len) { return ""; } else { return input.substring(beginIndex); } } else { return input; } } }