Java Parent Path Get getParentPathAndName(String path, StringBuilder parent)

Here you can find the source of getParentPathAndName(String path, StringBuilder parent)

Description

get Parent Path And Name

License

Open Source License

Declaration

public static String getParentPathAndName(String path, StringBuilder parent) 

Method Source Code


//package com.java2s;
import java.io.File;

public class Main {
    public static String getParentPathAndName(String path, StringBuilder parent) {
        final int len = path.length();
        final char sep = File.separatorChar;
        int end = 0;
        for (int i = 0; i < len; i++) {
            char ch = path.charAt(i);
            if (ch == sep) {
                ch = '/';
                end = i;/*from www .j a va2  s .co m*/
            } else if (ch == '/')
                end = i;
            parent.append(ch);
        }
        parent.setLength(end);
        return path.substring(end + 1);
    }
}

Related

  1. getParentPath(String absolutePath)
  2. getParentPath(String filePath)
  3. getParentPath(String fullpath)
  4. getParentPath(String path)
  5. getParentPath(String path)
  6. getParentPathname(String pathname)