Java Utililty Methods String Sub String

List of utility methods to do String Sub String

Description

The list of methods to do String Sub String are organized into topic(s).

Method

Stringsubstring(String string, int start, int length)
substring
if (length < 0)
    throw new IndexOutOfBoundsException("Parameter length cannot be negative.");
return string.substring(start, start + length);
Stringsubstring(String string, String beginning, String end)
substring
if (!string.contains(beginning) || !string.contains(end)
        || string.indexOf(beginning) >= string.indexOf(end))
    return null;
else {
    String after_beginning = string.substring(string.indexOf(beginning) + beginning.length());
    return after_beginning.substring(0, after_beginning.indexOf(end));
StringsubString(String string, String inizio, String fine)
taglia una stringa da un determinato carattere a un altro
String ritorno = null, stringaDaButtare = string;
if (contains(string, inizio) && contains(string, fine)) {
    int firstPosition = string.indexOf(inizio);
    firstPosition++;
    int secondPosition = string.indexOf(fine, firstPosition);
    ritorno = stringaDaButtare.substring(firstPosition, secondPosition);
return ritorno;
...
Stringsubstring(String subject, int start, int end)
substring
if (subject != null && start < subject.length()) {
    return subject.substring(start, end);
return "";
Stringsubstring(String text, int begin, int end)
substring
return text.substring(Math.min(text.length(), begin), Math.min(text.length(), end));
Stringsubstring(String text, int start, int end)
substring
if (text == null)
    return null;
int spos = text.offsetByCodePoints(0, start);
int epos = text.length() < end ? text.length() : end;
return text.substring(spos, text.offsetByCodePoints(spos, epos - start));
Stringsubstring(String text, int startPos, int endPos)
substring
String str = NVL(text);
str = fill(str, endPos);
return str.substring(startPos, endPos).trim();
Stringsubstring(String text, int startPos, int len)
Perform "substring" using start position and length.
assert validSubstring(text, startPos, len);
return text.substring(startPos, startPos + len);
StringsubString(String text, String leadingPart)
gets the substring of the given text reduced by the given leading part.
if (text.startsWith(leadingPart)) {
    return text.substring(leadingPart.length());
} else {
    return text;
StringsubString(String val, int start, int end)
sub String
if (!isEmpty(val) && val.length() >= end) {
    return val.substring(start, end);
return val;