Here you can find the source of chopLast(String value, int chars)
public static String chopLast(String value, int chars)
//package com.java2s; //License from project: Open Source License public class Main { /**// w w w .j av a 2 s . com * CHOP LAST */ public static String chopLast(String value, int chars) { if (chars < 0 || chars > value.length()) throw new IllegalArgumentException("invalid chars: " + chars + " / " + value.length()); return value.substring(0, value.length() - chars); } public static StringBuilder chopLast(StringBuilder value, int chars) { if (chars < 0 || chars > value.length()) throw new IllegalArgumentException("invalid chars: " + chars + " / " + value.length()); value.setLength(value.length() - chars); return value; } }