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

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

Description

sub String

License

LGPL

Declaration

public static String subString(String str, int start, int end) 

Method Source Code

//package com.java2s;
/*/* www.j av a  2  s .  c  om*/
 * MoXie (SysTem128@GMail.Com) 2009-3-11 10:06:36
 * 
 * Copyright © 2008-2009 Zoeey.Org
 * Code license: GNU Lesser General Public License Version 3
 * http://www.gnu.org/licenses/lgpl-3.0.txt
 */

public class Main {

    public static String subString(String str, int start, int end) {
        int strLen = str.length();
        start = start > strLen ? strLen : start;
        //
        start = start > 0 ? start : 0;
        //
        if (end == -1) {
            end = strLen;
        } else {
            end = end > strLen ? strLen : end;
        }
        //
        return str.substring(start, end);
    }
}

Related

  1. substring(String str, int off, int len)
  2. subString(String str, int offset, int leng)
  3. substring(String str, int start)
  4. substring(String str, int start)
  5. substring(String str, int start)
  6. substring(String str, int start, int end)
  7. substring(String str, int start, int end)
  8. substring(String str, int toCount)
  9. substring(String str, int toCount, String more)