public String simplifyPath(String path) {
        if (path == null || path.trim().length()==0){
            return "";
        }
        Stack<String> stack = new Stack<>();

        String[] tokens = path.split("/");
        for (String s : tokens){
            s = s.trim();
            if (s.isEmpty()){
                continue;
            }
            if (CUR.equals(s)){
                continue;
            }
            else if (UP.equals(s)){
                if (!stack.isEmpty()) {
                    stack.pop();
                }
            }
            else{
                stack.push(s);
            }
        }
        StringBuilder bldr = new StringBuilder();

        while (!stack.isEmpty()){
            bldr.insert(0, stack.pop());
            bldr.insert(0, "/");
        }

        return bldr.length()>0?bldr.toString():"/";
    }