Java Code Examples for org.apache.commons.io.FilenameUtils#getPathNoEndSeparator()

The following examples show how to use org.apache.commons.io.FilenameUtils#getPathNoEndSeparator() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MCRContent.java    From mycore with GNU General Public License v3.0 6 votes vote down vote up
private String getFilenameFromSystemId() {
    String fileName = systemId;
    String path = null;
    try {
        path = new URL(systemId).getPath();
    } catch (MalformedURLException e) {
        LogManager.getLogger(getClass()).debug("Could not get file name from URL.", e);
        try {
            path = new URI(systemId).getPath();
        } catch (URISyntaxException e2) {
            LogManager.getLogger(getClass()).debug("Could not get file name from URI.", e2);
        }
    }
    if (path != null) {
        fileName = path;
    }
    if (fileName.endsWith("/")) {
        fileName = FilenameUtils.getPathNoEndSeparator(fileName); //removes final '/';
    }
    return FilenameUtils.getName(fileName);
}
 
Example 2
Source File: ConfigurationUtils.java    From iaf with Apache License 2.0 6 votes vote down vote up
private void read() throws IOException, ConfigurationException {
	boolean isBuildInfoPresent = false;
	try (JarInputStream zipInputStream = new JarInputStream(getJar())) {
		ZipEntry zipEntry;
		while ((zipEntry = zipInputStream.getNextJarEntry()) != null) {
			if (!zipEntry.isDirectory()) {
				String entryName = zipEntry.getName();
				String fileName = FilenameUtils.getName(entryName);

				if(buildInfoFilename.equals(fileName)) {
					name = FilenameUtils.getPathNoEndSeparator(entryName);
					Properties props = new Properties();
					props.load(zipInputStream);
					version = getConfigurationVersion(props);

					isBuildInfoPresent = true;
					break;
				}
			}
		}
	}
	if(!isBuildInfoPresent) {
		throw new ConfigurationException("no ["+buildInfoFilename+"] persent in configuration");
	}
}
 
Example 3
Source File: MCRURLContent.java    From mycore with GNU General Public License v3.0 5 votes vote down vote up
public MCRURLContent(URL url) {
    super();
    this.url = url;
    this.setSystemId(url.toString());
    String fileName = url.getPath();
    if (fileName.endsWith("/")) {
        fileName = FilenameUtils.getPathNoEndSeparator(fileName); //removes final '/';
    }
    setName(FilenameUtils.getName(fileName));
}
 
Example 4
Source File: ModuleDetector.java    From analysis-model with MIT License 2 votes vote down vote up
/**
 * Returns the project name estimated from the build.gradle file path.
 *
 * @param buildScript
 *         Gradle build.gradle file path
 *
 * @return the project name or an empty string if the name could not be resolved
 */
private String parseGradle(final String buildScript) {
    String basePath = FilenameUtils.getPathNoEndSeparator(buildScript);
    String parentDirName = FilenameUtils.getName(basePath);
    return StringUtils.trimToEmpty(parentDirName);
}