Here you can find the source of getFilename(final String pPath)
Parameter | Description |
---|---|
pPath | The full filename path. |
public static String getFilename(final String pPath)
//package com.java2s; import java.io.*; public class Main { /**/*from ww w .j a v a 2 s .co m*/ * Extracts the filename of a complete filename path. * * @param pPath The full filename path. * @return the extracted filename. * @see File#getName * @see #getDirectoryname */ public static String getFilename(final String pPath) { return getFilename(pPath, File.separatorChar); } /** * Extracts the filename of a complete filename path. * * @param pPath The full filename path. * @param pSeparator The file separator. * @return the extracted filename. * @see File#getName * @see #getDirectoryname */ public static String getFilename(final String pPath, final char pSeparator) { int index = pPath.lastIndexOf(pSeparator); if (index < 0) { return pPath; // Assume only filename } return pPath.substring(index + 1); } }