public static void main(String[] args) {


        String fullPathToDir = "/a/b/c/";
        String rootFolder = fullPathToDir.substring(0, fullPathToDir.length() - 1);
        if (rootFolder.length() > 0) {
            rootFolder = rootFolder.substring(rootFolder.lastIndexOf("/") + 1);
        } else {
            rootFolder = "upload from ftp";
        }
        System.out.println(rootFolder);
    }