Here you can find the source of ltrim(final String str)
public static String ltrim(final String str)
//package com.java2s; //License from project: Open Source License public class Main { public static String ltrim(final String str) { int i;//from w w w . ja v a 2 s . co m int j; int x = 0; for (i = 0; i < str.length(); i++) { char ch = str.charAt(i); if (ch != ' ') { break; } } final int len = (str.length() - i); char[] res = new char[len]; for (j = i; j < str.length(); j++) { res[x++] = str.charAt(j); } return new String(res, 0, len); } }