public static String simplifyPath(String path) {
        if (path == null) {
            return null;
        }
        
        String[] tokens = path.split("/");
        LinkedList<String> stack = new LinkedList<String>();
        for (int i = 0; i < tokens.length; i++) {
            if (tokens[i].equals(".") || tokens[i].equals("")) {
                continue;
            }
            else if (tokens[i].equals("..")) {
                if (stack.isEmpty()) {
                    continue;
                }
                else {
                    stack.remove(stack.size() - 1);
                    continue;
                }
            }
            else {
                stack.add(tokens[i]);
            }
        }
        
        /* start building the simplified path */
        StringBuilder strbuilder = new StringBuilder("/");
        for (int i = 0; i < stack.size(); i++) {
            String name = stack.get(i);
            strbuilder.append(name);
            if (i < stack.size() - 1) {
                strbuilder.append("/");
            }
        }
        return strbuilder.toString();
    }