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(final String s, final int len)

Gets the leftmost len characters of a String.

if (s == null) {
    return null;
if (len < 0) {
    return "";
if (s.length() <= len) {
    return s;
...
Stringleft(final String string, final int length)
Returns leftmost characters of a string.
if (string == null || string.length() < length) {
    return string;
return string.substring(0, length);
Stringleft(final String text, final String sep)
left
final int pos = text.indexOf(sep);
if (pos != -1) {
    return text.substring(0, pos);
return text;
Stringleft(Object src, int length, String defaultValue)
left
if (src != null) {
    String temp = src.toString();
    if (temp.length() >= length) {
        return temp.substring(0, length);
    return temp;
return defaultValue;
...
Stringleft(String baseString, int pos)
left
int diLength;
if (baseString == null || pos <= 0) {
    return null;
} else {
    diLength = baseString.length();
    if (diLength < pos) {
        return baseString.substring(0);
    } else {
...
Stringleft(String s, int l)
left returns the left most characters of a string
try {
    return s.substring(0, l);
} catch (StringIndexOutOfBoundsException e) {
    return s;
Stringleft(String s, int len)
Gets the leftmost n characters of a string.
if (len < 0)
    throw new IllegalArgumentException("Requested String length " + len + " is less than zero");
return ((s == null) || (s.length() <= len)) ? s : s.substring(0, len);
Stringleft(String s, int nCaratteri)
left
if (s == null)
    return null;
if (nCaratteri < 1)
    return "";
if (nCaratteri >= s.length())
    return s;
return s.substring(0, nCaratteri);
Stringleft(String s, int size)
Basic-like Left$ function.
return s.substring(0, Math.min(size, s.length()));
Stringleft(String s, int width)
Left justify a string, padding with spaces.
return left(s, width, ' ');