Here you can find the source of chomp(String path)
public static String chomp(String path)
//package com.java2s; /*/*from www . j a va 2 s . c om*/ * This file is part of MML. * * MML is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2 of the License, or * (at your option) any later version. * * MML 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with MML. If not, see <http://www.gnu.org/licenses/>. * (c) copyright Desmond Schmidt 2014 */ public class Main { /** * Remove the rightmost segment of the path and resource * @return the remains of the path */ public static String chomp(String path) { String popped = ""; int index = path.lastIndexOf("/"); if (index != -1) popped = path.substring(0, index); return popped; } }