Here you can find the source of chop(String aString)
Parameter | Description |
---|---|
aString | a string to chop |
public static String chop(String aString)
//package com.java2s; /*//w ww . j a v a2 s . co m * Copyright (C) 2001-2003 Colin Bell * colbell@users.sourceforge.net * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ public class Main { /** * Chops off the very last character of the given string. * * @param aString a string to chop * @return the specified string minus it's last character, or null for null * or empty string for a string with length == 0|1. */ public static String chop(String aString) { if (aString == null) { return null; } if (aString.length() == 0) { return ""; } if (aString.length() == 1) { return ""; } return aString.substring(0, aString.length() - 1); } }