Java Utililty Methods URI to Local Name

List of utility methods to do URI to Local Name

Description

The list of methods to do URI to Local Name are organized into topic(s).

Method

StringgetLocalDomainURI(String originalHost, String dirPath, String childUri)
get Local Domain URI
if (childUri.contains(dirPath))
    return childUri;
if (childUri.startsWith("/"))
    childUri = childUri.substring(1);
try {
    URL url = new URL(childUri);
    String host = url.getHost();
    if (originalHost.equals(host)) {
...
StringgetLocalName(String uri)
get Local Name
if (uri.contains("/")) {
    int lastSlashPosition = uri.lastIndexOf("/");
    return uri.substring(lastSlashPosition + 1);
} else {
    return new String(uri);
StringgetLocalName(URI uri)
Return the local name of a URI.
return getLocalName(uri.toString());
StringgetLocalName(URI uri)
get Local Name
if (uri == null)
    return null;
return getLocalName(uri.toASCIIString());
StringgetLocalPart(String uri)
Get the local part of the uri, if possible.
try {
    URI u = new URI(uri);
    String lname = u.getFragment();
    if (lname == null) {
        lname = u.getPath();
    return lname;
} catch (URISyntaxException e) {
...
StringgetName(URI uri)
get Name
if (uri.getPath().contains("/"))
    return uri.getPath().substring(uri.getPath().lastIndexOf('/') + 1);
else
    return uri.getPath();
StringgetName(URI uri)
Returns the name of the file that is pointed to by this URI.
if (uri != null) {
    String location = uri.getSchemeSpecificPart();
    if (location != null) {
        String name = location;
        int index = location.lastIndexOf('/');
        if (index != -1) {
            name = name.substring(index + 1, name.length());
        return name;
return "";
StringgetName(URI uri)
Returns the name of an URI for display in the title bar of a window.
if (uri.getScheme() != null && uri.getScheme().equals("file")) {
    return new File(uri).getName();
return uri.toString();
StringgetName(URI uri)
Derives name from uri.
if (uri == null)
    return null;
if ("file".equals(uri.getScheme()))
    return new File(uri).getName();
return getURIName(uri);
StringgetName(URI uri)
Get the name.
if (uri == null)
    throw new IllegalArgumentException("Null uri");
String name = uri.getPath();
if (name != null) {
    int lastSlash = name.lastIndexOf('/');
    if (lastSlash > 0)
        name = name.substring(lastSlash + 1);
return name;