Here you can find the source of subStringRight(String str, int length)
public static String subStringRight(String str, int length)
//package com.java2s; //License from project: Open Source License public class Main { public static String subStringRight(String str, int length) { if (str == null || str.isEmpty()) return str; return str.substring(str.length() - min(str.length(), length)); }/*from w w w. j av a 2 s. c o m*/ /** * Check if Object (String) is empty or null (leading and trailing whitespaces and<br> * other chars like linefeed chars, etc. are omitted/ignored, like it was done in<br> * String.trim() method ) * * @param object * @return boolean, true if empty or null * @see empty */ public static boolean isEmpty(final CharSequence s) { int len; if (null != s && (len = s.length()) != 0) while (len > 0) if (s.charAt(--len) > ' ') return false; return true; } public static String substring(String in, int maxlength) { if (in.length() > maxlength) { return in.substring(0, maxlength); } return in; } private static int min(int a1, int a2) { return a1 < a2 ? a1 : a2; } }