drools-eclipse/org.guvnor.eclipse.webdav/src/client/org/eclipse/webdav/client/URLTool.java
public static URL removeTrailingSlash(URL url) {
        String file = url.getFile();

        if (file.endsWith("/")) { //$NON-NLS-1$
            file = file.substring(0, file.length() - 1);
            try {
                return new URL(url.getProtocol(), url.getHost(), url.getPort(), file);
            } catch (MalformedURLException e) {
                Assert.isTrue(false, e.getMessage());
            }
        } else {
            return url;
        }

        return null;
    }
public static URL removeTrailingSlash(URL url) {
        String file = url.getFile();

        if (file.endsWith("/")) { //$NON-NLS-1$
            file = file.substring(0, file.length() - 1);
            try {
                return new URL(url.getProtocol(), url.getHost(), url.getPort(), file);
            } catch (MalformedURLException e) {
                Assert.isTrue(false, e.getMessage());
            }
        } else {
            return url;
        }

        return null;
    }
Returns the given URL with its trailing slash removed. If the URL has
no trailing slash, the URL is returned unchanged.
<table>
<caption>Example</caption>
<tr>
<th>Given URL</th>
<th>Returned URL</th>
<tr>
<td>"http://hostname/folder"</td>
<td>"http://hostname/folder"</td>
<tr>
<td>"http://hostname/folder/</td>
<td>"http://hostname/folder"</td>
</table>

@param url a URL
@return    the given URL with its last slash removed