Here you can find the source of leftTrim(String str)
Parameter | Description |
---|---|
str | String to treat |
public static String leftTrim(String str)
//package com.java2s; /*/*from w ww . jav a2 s .com*/ * File: MiscUtil.java * Copyright (c) 2004-2007 Peter Kliem (Peter.Kliem@jaret.de) * A commercial license is available, see http://www.jaret.de. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Common Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/cpl-v10.html */ public class Main { /** * Removes leading whitespaces. * * @param str String to treat * @return str without leading whitespaces */ public static String leftTrim(String str) { if (str.length() == 0) { return str; } int i = 0; while (i < str.length()) { char c = str.charAt(i); if (Character.isWhitespace(c)) { i++; } else { break; } } return str.substring(i); } }