Here you can find the source of getParentPathAndName(String path, StringBuilder parent)
public static String getParentPathAndName(String path, StringBuilder parent)
//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); } }