Here you can find the source of ltrim(String s)
Parameter | Description |
---|---|
s | the string to edit |
public static final String ltrim(String s)
//package com.java2s; public class Main { /**//from www .j av a 2 s .co m * Trims the space characters from the beginning of a string. * For example, the call <CODE>ltrim ("eeTennessee", 'e')</CODE> * returns the string "Tennessee".<BR> * @param s the string to edit * @return the trimmed string */ public static final String ltrim(String s) { int count = s.length(); int st = 0; while ((st < count) && isSpace(s.charAt(st))) { st++; } return st > 0 ? s.substring(st, count) : s; } public static final boolean isSpace(String s) { if (s != null) { int len = s.length(); for (int i = 0; i < len; i++) { char c = s.charAt(i); if (c != ' ' && c != '\t' && c != '\n' && c != '\r') { return false; } } } return true; } private static boolean isSpace(char c) { return c <= ' '; } }