Here you can find the source of ltrim(String source)
Parameter | Description |
---|---|
str | The String to left trim |
public static String ltrim(String source)
//package com.java2s; //License from project: Apache License public class Main { /**/*from ww w .ja va 2 s. co m*/ * Left trim: remove spaces to the left of a String. * * @param str * The String to left trim * @return The left trimmed String */ public static String ltrim(String source) { if (source == null) return null; int from = 0; while (from < source.length() && isSpace(source.charAt(from))) from++; return source.substring(from); } /** * Determines whether or not a character is considered a space. A character * is considered a space in Kettle if it is a space, a tab, a newline or a * cariage return. * * @param c * The character to verify if it is a space. * @return true if the character is a space. false otherwise. */ public static final boolean isSpace(char c) { return c == ' ' || c == '\t' || c == '\r' || c == '\n'; } }