Java String Trim Left ltrim(String s, char character)

Here you can find the source of ltrim(String s, char character)

Description

ltrim

License

Open Source License

Declaration

public static String ltrim(String s, char character) 

Method Source Code

//package com.java2s;
//License from project: MIT License 

public class Main {
    public static String ltrim(String s) {
        int i = 0;
        while (i < s.length() && Character.isWhitespace(s.charAt(i))) {
            i++;//from   ww  w . j av a 2 s .  c o  m
        }
        return i(s, i);
    }

    public static String ltrim(String s, char character) {
        int i = 0;
        while (i < s.length() && s.charAt(i) == character) {
            i++;
        }
        return i(s, i);
    }

    public static String i(String s, int begin, int end) {
        if (s == null)
            return null;
        int len = s.length();
        if (begin < 0)
            begin += len;
        if (end < 0)
            end += len;
        if (begin < 0)
            begin = 0;
        if (end < 0)
            end = 0;
        if (begin >= len)
            return "";
        if (end > len)
            end = len;
        if (end <= begin)
            return "";
        return s.substring(begin, end);
    }

    public static String i(String s, int begin) {
        return i(s, begin, s.length());
    }
}

Related

  1. ltrim(String s)
  2. ltrim(String s)
  3. lTrim(String s)
  4. ltrim(String s)
  5. ltrim(String s)
  6. ltrim(String s, Character c)
  7. ltrim(String source)
  8. ltrim(String source)
  9. ltrim(String source)