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

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

Description

sub String

License

Open Source License

Declaration

public static String subString(String str, int len) 

Method Source Code

//package com.java2s;
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt

public class Main {
    public static String subString(String str, int len) {
        if (len < 0) {
            return str;
        }/*from  www.  ja  va2s .c  om*/
        if ("".equals(str) || str == null) {
            return null;
        } else if (str.length() <= len) {
            return str;
        } else {
            return str.substring(0, len);
        }
    }
}

Related

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