MCPcopy Create free account
hub / github.com/OpenSourcePhysics/osp / stripExtension

Method stripExtension

src/org/opensourcephysics/controls/XML.java:306–322  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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.

Callers 15

actionPerformedMethod · 0.95
actionPerformedMethod · 0.95
LauncherMethod · 0.95
openMethod · 0.95
startMethod · 0.95
mainMethod · 0.95
getThumbnailFileMethod · 0.95
getSearchCacheFileMethod · 0.95
createZipResourceMethod · 0.95
createResourceMethod · 0.95
getChooserSavePathMethod · 0.95

Calls 3

forwardSlashMethod · 0.95
getNameMethod · 0.95
lengthMethod · 0.80

Tested by 1

defineZipFilePathMethod · 0.76