org.apache.commons.io.FilenameUtils#getPathNoEndSeparator ( )源码实例Demo

下面列出了org.apache.commons.io.FilenameUtils#getPathNoEndSeparator ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: mycore   文件: MCRContent.java
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);
}
 
源代码2 项目: iaf   文件: ConfigurationUtils.java
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");
	}
}
 
源代码3 项目: mycore   文件: MCRURLContent.java
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));
}
 
源代码4 项目: analysis-model   文件: ModuleDetector.java
/**
 * 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);
}