Strips the extension from the specified file name. @param fileName the file name with or without path @return the file name without extension
(String fileName)
| 304 | * @return the file name without extension |
| 305 | */ |
| 306 | public static String stripExtension(String fileName) { |
| 307 | if(fileName==null) { |
| 308 | return null; |
| 309 | } |
| 310 | fileName = XML.forwardSlash(fileName); |
| 311 | int n = XML.forwardSlash(fileName).lastIndexOf("/"); //$NON-NLS-1$ |
| 312 | String name = getName(fileName); |
| 313 | int i = name.lastIndexOf('.'); |
| 314 | if((i>0)&&(i<name.length()-1)) { |
| 315 | name = name.substring(0, i); |
| 316 | } |
| 317 | fileName = fileName.substring(0, n+1)+name; |
| 318 | // strip off any extra dots at end |
| 319 | while (fileName.lastIndexOf('.')==fileName.length()-1 && fileName.length()>0) |
| 320 | fileName = fileName.substring(0, fileName.length()-1); |
| 321 | return fileName; |
| 322 | } |
| 323 | |
| 324 | /** |
| 325 | * Gets the path relative to the specified base directory. |