Java String Sub String substring(String baseString, int start, int end)

Here you can find the source of substring(String baseString, int start, int end)

Description

substring

License

LGPL

Declaration

public static final String substring(String baseString, int start, int end) 

Method Source Code

//package com.java2s;
/**//from  w w w .j  a  va  2 s. c o m
* Converts a line of text into an array of lower case words using a
* BreakIterator.wordInstance().
* <p>
* 
* This method is under the Jive Open Source Software License and was written
* by Mark Imbriaco.
* 
* @param text
*          a String of text to convert into an array of words
* @return text broken up into an array of words.
*/

public class Main {

    public static final String substring(String baseString, int start, int end) {
        if (baseString == null)
            return null;
        else if (start >= baseString.length() || start < 0 || end < 0 || start > end)
            return null;
        else if (end >= baseString.length())
            return baseString.substring(start);
        else {
            return baseString.substring(start, end);
        }
    }

    public static final String substring(String baseString, int start) {
        if (baseString == null)
            return null;
        else
            return substring(baseString, start, baseString.length());
    }

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

Related

  1. substring(final String s, int startIndex, int endIndex)
  2. substring(final String str, int start, int end)
  3. substring(final String string, int fromIndex, int toIndex)
  4. substring(final String text, final int position, final int length)
  5. substring(String _text, int _idx)
  6. subString(String input, char start, char end)
  7. substring(String input, int expectedLength)
  8. substring(String input, int maxLength)
  9. substring(String input, int maxLength)