Java URI to Local Name getName(URI uri)

Here you can find the source of getName(URI uri)

Description

Returns the name of an URI for display in the title bar of a window.

License

Open Source License

Declaration

public static String getName(URI uri) 

Method Source Code

//package com.java2s;
/*/*  w w w  . j  ava2s  .  c  o m*/
 * @(#)URIUtil.java
 * 
 * Copyright (c) 2009-2010 by the original authors of JHotDraw and all its
 * contributors. All rights reserved.
 * 
 * You may not use, copy or modify this file, except in compliance with the 
 * license agreement you entered into with the copyright holders. For details
 * see accompanying license terms.
 */

import java.io.File;
import java.net.URI;

public class Main {
    /** Returns the name of an URI for display in the title bar of a window. */
    public static String getName(URI uri) {
        if (uri.getScheme() != null && uri.getScheme().equals("file")) {
            return new File(uri).getName();
        }
        return uri.toString();
    }
}

Related

  1. getLocalName(URI uri)
  2. getLocalName(URI uri)
  3. getLocalPart(String uri)
  4. getName(URI uri)
  5. getName(URI uri)
  6. getName(URI uri)
  7. getName(URI uri)
  8. getName(URI uri)
  9. getNameSpace(URI uri)