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: Open Source License public class Main { public static String substring(String input, int maxLength) { if (input == null) return null; else/* w w w . j a va 2 s.c om*/ return (input.length()) <= maxLength ? input : input.substring(0, maxLength); } }