Here you can find the source of getFilename(final String filenamePath)
public static String getFilename(final String filenamePath)
//package com.java2s; //License from project: Open Source License import java.io.File; public class Main { public static String DIRECTORY_SEPARATOR = File.separator; /**/*from w w w.j ava 2 s.co m*/ * Retourniert Dateinamen ohne Pfad als String */ public static String getFilename(final String filenamePath) { String correctFilenamePath = getCorrectSeparators(filenamePath); if (correctFilenamePath.indexOf(DIRECTORY_SEPARATOR) < 0) { return filenamePath; } return correctFilenamePath.substring(correctFilenamePath.lastIndexOf(DIRECTORY_SEPARATOR) + 1, correctFilenamePath.length()); } private static String getCorrectSeparators(final String pathOrFilename) { return pathOrFilename.replace("\\", DIRECTORY_SEPARATOR).replace("//", //$NON-NLS-1$ //$NON-NLS-2$ DIRECTORY_SEPARATOR).replace("/", DIRECTORY_SEPARATOR); //$NON-NLS-1$ } }