Java String Truncate truncateUri(String uri)

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

Description

truncate Uri

License

Open Source License

Declaration

public static String truncateUri(String uri) 

Method Source Code

//package com.java2s;
/**/* w w w . ja v a2s  . c  om*/
 * Copyright (C) 2009 G?nter Ladwig (gla at aifb.uni-karlsruhe.de)
 * 
 * This file is part of the graphindex project.
 *
 * graphindex is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License, version 2
 * as published by the Free Software Foundation.
 * 
 * graphindex is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with graphindex.  If not, see <http://www.gnu.org/licenses/>.
 */

public class Main {
    public static String truncateUri(String uri) {
        if (uri == null)
            return null;
        int idx = uri.lastIndexOf("#");
        if (idx < 0)
            idx = uri.lastIndexOf("/");
        if (idx < 0)
            return uri;
        return uri.substring(idx + 1);
    }
}

Related

  1. truncateToFirstLine(String string)
  2. truncateToLength(String inputString, int truncateLength)
  3. truncateToMaxLen(String input, int len)
  4. truncateType(String s)
  5. truncateType(String type)
  6. truncateUrl(String url)
  7. TruncateUrlPage(String strURL)
  8. truncateValue(String value, int limit, String endChars)
  9. truncateWhenUTF8(final String s, final int maxBytes)