public static String normalizePath(String path)
    {
        StringBuilder sb = new StringBuilder(path);
        int lastToken = -1;
        for (int i = 0; i < sb.length(); i++)
        {
            if ((sb.charAt(i) == File.separatorChar)
                || (sb.charAt(i) == '/'))
            {
                if (lastToken != -1)
                {
                    if (i < sb.length() - 2)
                        if (sb.charAt(i + 1) == '.')
                            if (sb.charAt(i + 2) == '.')
                    {   // Remove last directory name from path
                        sb.delete(lastToken, i + 3);
                        i = lastToken;
                    }
                }
                lastToken = i;
            }
        }
        return sb.toString();
    }
public static String normalizePath ( String path ) { StringBuilder sb = new StringBuilder ( path ) ; int lastToken = - 1 ; for ( int i = 0 ; i < sb . length ( ) ; i ++ ) { if ( ( sb . charAt ( i ) == File . separatorChar ) || ( sb . charAt ( i ) == '/' ) ) { if ( lastToken != - 1 ) { if ( i < sb . length ( ) - 2 ) if ( sb . charAt ( i + 1 ) == '.' ) if ( sb . charAt ( i + 2 ) == '.' ) { sb . delete ( lastToken , i + 3 ) ; i = lastToken ; } } lastToken = i ; } } return sb . toString ( ) ; }
Change this to a straight path name without /../ references (Required for 'create directory').
@return The new path string.