Java String Truncate truncateFirstEnd(String str)

Here you can find the source of truncateFirstEnd(String str)

Description

truncate First End

License

Apache License

Declaration

public static String truncateFirstEnd(String str) 

Method Source Code

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

public class Main {

    public static String truncateFirstEnd(String str) {
        if (isEmpty(str))
            return str;

        String tmp = str.substring(1);
        return tmp.substring(0, tmp.length() - 1);
    }/*from w  ww  . j  av  a  2s .  c o m*/

    public static boolean isEmpty(String str) {
        return str == null || (str.trim().length() == 0);
    }

    public static String subString(String src, String begin, String end) {
        return subString(src, 0, begin, end);
    }

    public static String subString(String src, int offset, String begin, String end) {
        if (isEmpty(src) || offset >= src.length())
            return "";
        int b = offset;
        int e = src.length();
        if (!isEmpty(begin)) {
            b = src.indexOf(begin, offset);
            if (b < 0)
                return "";
            b += begin.length();
        }
        if (!isEmpty(end) && b < e) {
            e = src.indexOf(end, b);
            if (e < 0)
                e = src.length();
        }
        return src.substring(b, e);
    }
}

Related

  1. truncateDatabaseName(String db)
  2. truncatedStr(String s, int maxLength)
  3. truncateExtension(String name)
  4. truncateFileName(String agent, String s)
  5. truncateFileType(String p)
  6. truncateHashToInt(String hash)
  7. truncateIfTooLong(String string, int maxLength)
  8. truncateIgnoreCase(String aString, String trailingSubString)
  9. truncateInt(String intStr)