Java String Sub String substringEnd(String string, int start, int length)

Here you can find the source of substringEnd(String string, int start, int length)

Description

Substrings the string using start index and length, that defines the number of characters in the substringed string.

License

Open Source License

Parameter

Parameter Description
string The string
start The start index
length The length

Return

The substringed string

Declaration

public static String substringEnd(String string, int start, int length) 

Method Source Code

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

public class Main {
    /**/*from w  ww. ja  v  a2 s.com*/
     * Substrings the string using start index and
     * length, that defines the number of characters
     * in the substringed string. The end index is
     * as following: <code>end = start + length</code>.
     * @param string The string
     * @param start  The start index
     * @param length The length
     * @return The substringed string*/
    public static String substringEnd(String string, int start, int length) {
        return string.substring(start, Math.max(start, string.length()
                - Math.min(start + length, string.length())));
    }
}

Related

  1. subStringByte(String str, int toCount, String more)
  2. substringBytes(String value, int byte_len)
  3. substringCompare(String string, int index, char... characters)
  4. substringDelimited(String string, String start, String end, int startingPosition)
  5. substringEL(String str, int index, String defaultValue)
  6. substringEquals(final String s1, final int fromIndex1, final int toIndex1, final String s2, final int fromIndex2, final int toIndex2)
  7. subStringExe(String s, String jmp, String sb, String se)
  8. substringFromMatch(String match, String string)
  9. substringFromMultiValuedFields(int start, int end, String[] fieldValues, int offsetGap, String interFieldJoiner)