Here you can find the source of pathTo(String filename)
public static String pathTo(String filename)
//package com.java2s; public class Main { public static String pathTo(String filename) { String result = ""; int p = filename.lastIndexOf('/'); if (p >= 0) { result = filename.substring(0, p); }/*from w w w .ja v a 2s . co m*/ return result; } public static String substring(StringBuffer buf, int start, int lim) { int len = lim - start; char[] result = new char[len]; buf.getChars(start, lim, result, 0); return String.valueOf(result); } }