de.tla2b.util.FileUtils Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of tla2bAST Show documentation
Show all versions of tla2bAST Show documentation
Translator from TLA+ to ProB's AST representation.
The newest version!
package de.tla2b.util;
import java.io.File;
public class FileUtils {
public static String removeExtension(String filePath) {
File f = new File(filePath);
// if it's a directory, don't remove the extension
if (f.isDirectory())
return filePath;
String name = f.getName();
// Now we know it's a file - don't need to do any special hidden
// checking or contains() checking because of:
final int lastPeriodPos = name.lastIndexOf('.');
if (lastPeriodPos <= 0) {
// No period after first character - return name as it was passed in
return filePath;
} else {
// Remove the last period and everything after it
File renamed = new File(f.getParent(), name.substring(0, lastPeriodPos));
return renamed.getPath();
}
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy