Here you can find the source of extractFilename(String path)
Parameter | Description |
---|---|
path | The path to extract the filename from |
public static String extractFilename(String path)
//package com.java2s; /******************************************************************************* * Copyright (C) 2013 Research In Motion Limited * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html *******************************************************************************/ public class Main { /**/*from w w w . j a v a 2 s.c om*/ * Extract the filename from a (relative or absolute) path. Works with both * / and \ separators. * * @param path * The path to extract the filename from * @return The filename portion of path */ public static String extractFilename(String path) { String result = path.substring(path.lastIndexOf('/') + 1); return result.substring(result.lastIndexOf('\\') + 1); } }