Java URI to Local Name getLocalName(String uri)

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

Description

get Local Name

License

Open Source License

Declaration

public static String getLocalName(String uri) throws MalformedURLException 

Method Source Code

//package com.java2s;
/**/*from w w w .j a  v a2s  .co  m*/
 * (C) Copyright 2015 Zaizi Limited (http://www.zaizi.com).
 *
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the GNU Lesser General Public License
 * (LGPL) version 3.0 which accompanies this distribution, and is available at 
 * http://www.gnu.org/licenses/lgpl-3.0.en.html
 *
 * This library 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
 * Lesser General Public License for more details.
 *
 **/

import java.net.MalformedURLException;

public class Main {
    public static String getLocalName(String uri) throws MalformedURLException {
        if (uri.contains("/")) {
            int lastSlashPosition = uri.lastIndexOf("/");
            return uri.substring(lastSlashPosition + 1);
        } else {
            return new String(uri);
        }
    }
}

Related

  1. getLocalDomainURI(String originalHost, String dirPath, String childUri)
  2. getLocalName(URI uri)
  3. getLocalName(URI uri)
  4. getLocalPart(String uri)
  5. getName(URI uri)