i'not done messing with FileUtil :)

here's the problem:
catPath throws an ArrayIndexOutOfBoundsException if lookupPath
(the base path) does not contain any '/' char.

so, i've attached a replacement method.
the change in the new version are :
- no more ArrayIndexOutOfBoundsException, therefore support
  of relative path is ok.
- output is normalized (wich makes the code significantly simplier,
  but also often slower).
- always throws NullPointerException if any parameter is null.
    /*
     * addition to javadoc :
     *
     * - this method handles java/unix style path only (separator is '/').
     * - it handles absolute and relative path.
     * - returned path is normalized (as with method <code>normalize<code>).
     *
     * @see #normalize
     * @throws NullPointerException if any parameter is null.
     */

    public static String catPath( String lookupPath, final String path )
    {
        if (path == null)
            throw new NullPointerException ("path is null.");

        if (!lookupPath.endsWith ("/"))
        {
            int index = lookupPath.lastIndexOf ("/");

            if (index < 0)
            {
                lookupPath = "";
            }
            else
            {
                lookupPath = lookupPath.substring (0, index+1);
            }
        }

        return normalize (lookupPath + path);
    }
--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to