Java String Truncate truncateLeadingSlash(String uri)

Here you can find the source of truncateLeadingSlash(String uri)

Description

Any leading / in the given uri will be removed.

License

Apache License

Parameter

Parameter Description
uri the Uri to remove leading slashes from.

Return

the Uri without leading slashes.

Declaration

public static String truncateLeadingSlash(String uri) 

Method Source Code

//package com.java2s;
/*/*from  w  w  w. ja va  2s. c  o m*/
 * $Header: /var/chroot/cvs/cvs/factsheetDesigner/extern/jakarta-slide-server-src-2.1-iPlus Edit/src/webdav/server/org/apache/slide/webdav/util/PropertyHelper.java,v 1.2 2006-01-22 22:55:21 peter-cvs Exp $
 * $Revision: 1.2 $
 * $Date: 2006-01-22 22:55:21 $
 *
 * ====================================================================
 *
 * Copyright 1999-2002 The Apache Software Foundation
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 */

public class Main {
    /**
     * Any leading <code>/</code> in the given <code>uri</code> will be removed.
     *
     * @param      uri  the Uri to remove leading slashes from.
     *
     * @return     the Uri without leading slashes.
     */
    public static String truncateLeadingSlash(String uri) {

        if (uri == null) {
            return uri;
        }

        while (uri.startsWith("/")) {
            uri = uri.substring(1);
        }
        return uri;
    }
}

Related

  1. truncateIfTooLong(String string, int maxLength)
  2. truncateIgnoreCase(String aString, String trailingSubString)
  3. truncateInt(String intStr)
  4. truncateJavaBeanMethodName(String methodName, int prefixLength)
  5. truncateLabel(String label)
  6. truncateLongName(String name, int nameLength)
  7. truncateLongStr(String str)
  8. truncateMessage(String message, int TRUNCATED_MSG_SIZE)
  9. truncateMessageIn50000Characters(final String message)