Here you can find the source of getDirName(String dir)
private static String getDirName(String dir)
import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import org.apache.log4j.Logger; public class Main{ private static final String separator = "/"; /*from www . j av a 2 s . c om*/ private static String getDirName(String dir) { if (dir.endsWith(separator)) { dir = dir.substring(0, dir.lastIndexOf(separator)); } return dir.substring(dir.lastIndexOf(separator) + 1); } }