Java URI to File Name getFileName(URI uri)

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

Description

get File Name

License

Open Source License

Declaration

public static String getFileName(URI uri) 

Method Source Code

//package com.java2s;
/**/* ww w. ja va 2 s .  co  m*/
 * Aptana Studio
 * Copyright (c) 2005-2011 by Appcelerator, Inc. All Rights Reserved.
 * Licensed under the terms of the GNU Public License (GPL) v3 (with exceptions).
 * Please see the license.html included with this distribution for details.
 * Any modifications to this file must keep this entire header intact.
 */

import java.net.URI;

import org.eclipse.core.runtime.IPath;

import org.eclipse.core.runtime.Path;

public class Main {
    public static String getFileName(URI uri) {
        if (uri == null) {
            return null;
        }
        String uriPath = uri.getPath();
        IPath path = Path.fromPortableString(uriPath);
        if (path == null) {
            return null;
        }
        return path.lastSegment();
    }
}

Related

  1. getFilename(final URI uri)
  2. getFilename(final URI uri)
  3. getFileName(URI path)
  4. getFileName(URI uri)
  5. getFileName(URI uri)
  6. getFileName(URI uri)
  7. getFileNameFromURI(final URI resourceAddress, final boolean usePathStyleUris)
  8. getFilenameFromURI(URI uri, boolean preserveExtension)
  9. getFilePart(String uri)