Java String Sub String subString(String str, int end)

Here you can find the source of subString(String str, int end)

Description

sub String

License

Open Source License

Declaration

public static String subString(String str, int end) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    public static String subString(String str, int end) {
        return subString(str, 0, end, "...");
    }/* w  w w  .  j a v a 2s  .  co  m*/

    public static String subString(String str, int start, int end, String suffix) {
        if (str == null)
            return str;
        try {
            return str.substring(start, end > str.length() ? str.length() : end)
                    + (end < str.length() ? suffix : "");
        } catch (Exception e) {
            return str;
        }
    }

    public static String subString(String str, int start, int end) {
        return subString(str, start, end, "");
    }

    public static int length(String str) {
        if (str == null)
            return 0;
        return str.length();
    }
}

Related

  1. substring(String str, int beginIndex)
  2. subString(String str, int beginIndex, int endIndex)
  3. substring(String str, int beginIndex, int endIndex)
  4. substring(String str, int beginIndex, int endIndex)
  5. substring(String str, int beginIndex, int len)
  6. substring(String str, int index, int length)
  7. subString(String str, int len)
  8. substring(String str, int len)
  9. subString(String str, int num, String token)