Java Path Tail tail(String path)

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

Description

tail

License

Open Source License

Declaration

public static String tail(String path) 

Method Source Code

//package com.java2s;
/*//from   w  w  w  .j a  v  a 2 s. c o m
 * ====================================================================
 * Copyright (c) 2004-2012 TMate Software Ltd.  All rights reserved.
 *
 * This software is licensed as described in the file COPYING, which
 * you should have received as part of this distribution.  The terms
 * are also available at http://svnkit.com/license.html
 * If newer versions of this license are posted there, you may use a
 * newer version instead, at your option.
 * ====================================================================
 */

public class Main {
    public static String tail(String path) {
        int index = path.length() - 1;
        if (index >= 0 && index < path.length() && path.charAt(index) == '/') {
            index--;
        }
        for (int i = index; i >= 0; i--) {
            if (path.charAt(i) == '/') {
                return path.substring(i + 1, index + 1);
            }
        }
        return path;
    }
}

Related

  1. tail(String path)
  2. tail(String path)