Here you can find the source of getURIName(String forwardSlashPath)
Parameter | Description |
---|---|
forwardSlashPath | whose path to get name of. |
public static String getURIName(String forwardSlashPath)
//package com.java2s; import java.net.URI; public class Main { /**//from w w w .ja v a 2 s. com * Path is parsed using '/' as separator. * * @param forwardSlashPath * whose path to get name of. * @return name of file or directory. */ public static String getURIName(String forwardSlashPath) { if (forwardSlashPath == null) return null; int end = forwardSlashPath.length(); if (end == 0) return ""; if (forwardSlashPath.charAt(end - 1) == '/') end = end - 1; if (end == 0) return "/"; int index = forwardSlashPath.substring(0, end).lastIndexOf('/'); return forwardSlashPath.substring(index + 1, end); } /** * Derives name from uri; calls overloaded method. the uri path is parsed * using '/' as separator. * * @param uri * whose path to get name of. * @return name of file or directory. */ public static String getURIName(URI uri) { if (uri == null) return null; return getURIName(uri.getPath()); } }