Here you can find the source of substring(String input, int maxLength)
public static String substring(String input, int maxLength)
//package com.java2s; //License from project: Apache License public class Main { public static String substring(String input, int maxLength) { if (input == null) { return null; }/* ww w . jav a 2 s .c o m*/ if (maxLength < 0) { return input; } if (input.length() > maxLength) { return input.substring(0, maxLength); } return input; } public static int length(String input) { return input == null ? 0 : input.length(); } }