Java Utililty Methods String Left

List of utility methods to do String Left

Description

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

Method

Stringleft(String source, int length)
left
if (source == null) {
    return null;
return ((length > source.length()) ? source : source.substring(0, length));
Stringleft(String source, String searchFor)
left
String resultado = source;
int index = source.indexOf(searchFor);
if (index > 0)
    resultado = source.substring(0, index);
return resultado;
Stringleft(String source, String searchFor)
Returns the substring to the left of the specified substring in the specified String, starting from the left.
int index = source.indexOf(searchFor);
if (index <= 0) {
    return "";
return source.substring(0, index);
Stringleft(String str, int count)
Returns the first n characters from this string, where n = count.
if (str == null) {
    return null;
if (str.length() < count) {
    return str;
return str.substring(0, count);
Stringleft(String str, int len)
left
return (str == null) ? null : ((len < 0) ? "" : ((str.length() <= len) ? str : str.substring(0, len)));
Stringleft(String str, int len)

Gets the leftmost len characters of a String.

If len characters are not available, or the String is null, the String will be returned without an exception.

if (str == null) {
    return null;
if (len < 0) {
    return EMPTY;
if (str.length() <= len) {
    return str;
...
Stringleft(String str, int len)
Get substring from left
if (!nullOrEmpty(str) && str.length() > len) {
    return str.substring(0, len);
return str;
Stringleft(String str, int len)
return str.substring(0,endIdx) *
return str.substring(0, len);
Stringleft(String str, int len, String appendStrIfOver)
left
if (str == null) {
    return null;
if (str.length() <= len) {
    return str;
if (appendStrIfOver == null || appendStrIfOver.isEmpty()) {
    return str.substring(0, len);
...
Stringleft(String str, int length)
left of string
String rc = NVL(str);
if (rc.length() <= length) {
    return str;
return rc.substring(0, length);