Java String Chomp chomp(String path)

Here you can find the source of chomp(String path)

Description

Remove the rightmost segment of the path and resource

License

Open Source License

Return

the remains of the path

Declaration

public static String chomp(String path) 

Method Source Code

//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;
    }
}

Related

  1. chomp(CharSequence prefix, CharSequence full)
  2. chomp(final String s, final String suffix)
  3. chomp(String in)
  4. chomp(String inStr)
  5. chomp(String options)
  6. chomp(String s)
  7. chomp(String s)
  8. chomp(String sd, String c)
  9. chomp(String str)