Java tutorial
//package com.java2s; import java.io.File; public class Main { public static String getPathFromFilepath(String path) { int index = path.lastIndexOf(File.separator); String p = File.separator; if (index != -1) { p = path.substring(0, index); } return p; } }