jetbrick-commons/src/main/java/jetbrick/lang/StringUtils.java
public static String mid(final String s, int pos, final int len) {
        if (s == null) {
            return null;
        }
        if (len < 0 || pos > s.length()) {
            return "";
        }
        if (pos < 0) {
            pos = 0;
        }
        if (s.length() <= pos + len) {
            return s.substring(pos);
        }
        return s.substring(pos, pos + len);
    }
public static String mid(final String s, int pos, final int len) {
        if (s == null) {
            return null;
        }
        if (len < 0 || pos > s.length()) {
            return "";
        }
        if (pos < 0) {
            pos = 0;
        }
        if (s.length() <= pos + len) {
            return s.substring(pos);
        }
        return s.substring(pos, pos + len);
    }
<p>
Gets {@code len} characters from the middle of a String.
</p>

<p>
If {@code len} characters are not available, the remainder of the String
will be returned without an exception. If the String is {@code null},
{@code null} will be returned. An empty String is returned if len is
negative or exceeds the length of {@code str}.
</p>

<pre>
StringUtils.mid(null, *, *)    = null
StringUtils.mid(*, *, -ve)     = ""
StringUtils.mid("", 0, *)      = ""
StringUtils.mid("abc", 0, 2)   = "ab"
StringUtils.mid("abc", 0, 4)   = "abc"
StringUtils.mid("abc", 2, 4)   = "c"
StringUtils.mid("abc", 4, 2)   = ""
StringUtils.mid("abc", -2, 2)  = "ab"
</pre>