Here you can find the source of ltrim(String str, String defaultValue)
Parameter | Description |
---|---|
str | String to clean |
public static String ltrim(String str, String defaultValue)
//package com.java2s; //License from project: LGPL public class Main { /** /* www . j a v a 2 s . c o m*/ * This function returns a string with whitespace stripped from the beginning of str * @param str String to clean * @return cleaned String */ public static String ltrim(String str, String defaultValue) { if (str == null) return defaultValue; int len = str.length(); int st = 0; while ((st < len) && (str.charAt(st) <= ' ')) { st++; } return ((st > 0)) ? str.substring(st) : str; } public static int length(String str) { if (str == null) return 0; return str.length(); } /** * this method works different from the regular substring method, the regular substring method takes startIndex and endIndex as second and third argument, * this method takes offset and length * @param str * @param off * @param len * @return */ public static String substring(String str, int off, int len) { return str.substring(off, off + len); } }