Android Path Create getParentNameofPath(String path)

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

Description

get Parent Nameof Path

Declaration

public static String getParentNameofPath(String path) 

Method Source Code

//package com.java2s;

public class Main {

    public static String getParentNameofPath(String path) {
        if (path.equals("/")) {
            return null;
        }/*from w  w w  .  j  av  a 2  s.  c  o  m*/
        if (path.endsWith("/")) {
            path = path.substring(0, path.length() - 1);
        }
        int index = path.lastIndexOf('/');
        if (path.length() == 1) {
            return path;
        }
        if (index == 0) {
            return "/";
        }
        return path.substring(0, index);
    }
}

Related

  1. getNameDelLastPath(String fileName)
  2. getPath(String path, String parent)
  3. getRealPath(String name)
  4. getFullPath(String inBaseUrl, String inUrl)
  5. getNameAppendStr(String path, String Str)