Here you can find the source of extractFileName(String path)
Parameter | Description |
---|---|
inPath | a parameter |
public static String extractFileName(String path)
//package com.java2s; /*// w ww . ja v a 2s . c o m Copyright (c) 2003 eInnovation Inc. All rights reserved This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. */ public class Main { /** * Pass in /sub/dir/path.html returns path.html * * @param inPath * @return */ public static String extractFileName(String path) { if (path == null) { return null; } String newpath = path.replace('\\', '/'); int start = newpath.lastIndexOf("/"); if (start == -1) { start = 0; } else { start = start + 1; } String pageName = newpath.substring(start, newpath.length()); return pageName; } }