Here you can find the source of clampString(String string, int limit)
public static String clampString(String string, int limit)
//package com.java2s; //License from project: Open Source License public class Main { public static String clampString(String string, int limit) { return string.substring(0, string.length() > limit ? limit : string.length()); }/*from w w w . j a va 2 s . c o m*/ }