当前位置: 首页>>代码示例>>Java>>正文


Java StringUtils.getFilenameExtension方法代码示例

本文整理汇总了Java中org.springframework.util.StringUtils.getFilenameExtension方法的典型用法代码示例。如果您正苦于以下问题:Java StringUtils.getFilenameExtension方法的具体用法?Java StringUtils.getFilenameExtension怎么用?Java StringUtils.getFilenameExtension使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.springframework.util.StringUtils的用法示例。


在下文中一共展示了StringUtils.getFilenameExtension方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: fromPath

import org.springframework.util.StringUtils; //导入方法依赖的package包/类
public static MavenCoordinates fromPath(String path) {
	if (path.startsWith("/")) {
		path = path.substring(1);
	}
	Matcher folderMatcher = FOLDER_PATTERN.matcher(path);
	Assert.state(folderMatcher.matches(), "Unable to parse " + path);
	String groupId = folderMatcher.group(1).replace('/', '.');
	String artifactId = folderMatcher.group(2);
	String version = folderMatcher.group(3);
	String rootVersion = (version.endsWith(SNAPSHOT_SUFFIX)
			? version.substring(0, version.length() - SNAPSHOT_SUFFIX.length())
			: version);
	String name = folderMatcher.group(4);
	String snapshotVersionAndClassifier = name.substring(artifactId.length() + 1);
	String extension = StringUtils.getFilenameExtension(snapshotVersionAndClassifier);
	snapshotVersionAndClassifier = snapshotVersionAndClassifier.substring(0,
			snapshotVersionAndClassifier.length() - extension.length() - 1);
	String classifier = snapshotVersionAndClassifier;
	if (classifier.startsWith(rootVersion)) {
		classifier = classifier.substring(rootVersion.length());
		classifier = stripDash(classifier);
	}
	Matcher versionMatcher = VERSION_FILE_PATTERN.matcher(classifier);
	if (versionMatcher.matches()) {
		classifier = versionMatcher.group(3);
		classifier = stripDash(classifier);
	}
	if (classifier.startsWith(SNAPSHOT)) {
		classifier = classifier.substring(SNAPSHOT.length());
		classifier = stripDash(classifier);
	}
	String snapshotVersion = (classifier.isEmpty() ? snapshotVersionAndClassifier
			: snapshotVersionAndClassifier.substring(0,
					snapshotVersionAndClassifier.length() - classifier.length() - 1));
	return new MavenCoordinates(groupId, artifactId, version, classifier, extension,
			snapshotVersion);
}
 
开发者ID:spring-io,项目名称:artifactory-resource,代码行数:38,代码来源:MavenCoordinates.java

示例2: getMediaTypeKey

import org.springframework.util.StringUtils; //导入方法依赖的package包/类
@Override
protected String getMediaTypeKey(NativeWebRequest webRequest) {
	HttpServletRequest servletRequest = webRequest.getNativeRequest(HttpServletRequest.class);
	if (servletRequest == null) {
		logger.warn("An HttpServletRequest is required to determine the media type key");
		return null;
	}
	String path = urlPathHelper.getLookupPathForRequest(servletRequest);
	String filename = WebUtils.extractFullFilenameFromUrlPath(path);
	String extension = StringUtils.getFilenameExtension(filename);
	return (StringUtils.hasText(extension)) ? extension.toLowerCase(Locale.ENGLISH) : null;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:13,代码来源:PathExtensionContentNegotiationStrategy.java

示例3: generate

import org.springframework.util.StringUtils; //导入方法依赖的package包/类
private void generate(Directory root, File pomFile) {
	String name = StringUtils.getFilename(pomFile.getName());
	String extension = StringUtils.getFilenameExtension(pomFile.getName());
	String prefix = name.substring(0, name.length() - extension.length() - 1);
	File[] files = pomFile.getParentFile().listFiles((f) -> include(f, prefix));
	MultiValueMap<File, MavenCoordinates> coordinates = new LinkedMultiValueMap<>();
	for (File file : files) {
		String rootPath = StringUtils.cleanPath(root.getFile().getPath());
		String relativePath = StringUtils.cleanPath(file.getPath())
				.substring(rootPath.length() + 1);
		coordinates.add(file.getParentFile(),
				MavenCoordinates.fromPath(relativePath));
	}
	coordinates.forEach(this::writeMetadata);
}
 
开发者ID:spring-io,项目名称:artifactory-resource,代码行数:16,代码来源:MavenMetadataGenerator.java

示例4: include

import org.springframework.util.StringUtils; //导入方法依赖的package包/类
private boolean include(File file, String prefix) {
	String extension = StringUtils.getFilenameExtension(file.getName());
	if (IGNORED_EXTENSIONS.contains(extension.toLowerCase())) {
		return false;
	}
	return file.exists() && file.isFile()
			&& StringUtils.getFilename(file.getName()).startsWith(prefix);
}
 
开发者ID:spring-io,项目名称:artifactory-resource,代码行数:9,代码来源:MavenMetadataGenerator.java

示例5: isHandled

import org.springframework.util.StringUtils; //导入方法依赖的package包/类
private boolean isHandled(String path) {
  String extension = StringUtils.getFilenameExtension(path);
  return handledExtensions.stream().anyMatch(ext -> ext.equals(extension));
}
 
开发者ID:2DV603NordVisaProject,项目名称:nordvisa_calendar,代码行数:5,代码来源:AppConfig.java

示例6: getFileExtension

import org.springframework.util.StringUtils; //导入方法依赖的package包/类
private String getFileExtension(File file) {
	return StringUtils.getFilenameExtension(file.getName());
}
 
开发者ID:spring-io,项目名称:artifactory-resource,代码行数:4,代码来源:FileComparator.java

示例7: getNameWithoutExtension

import org.springframework.util.StringUtils; //导入方法依赖的package包/类
private static String getNameWithoutExtension(File file) {
	String name = file.getName();
	String extension = StringUtils.getFilenameExtension(name);
	return (extension == null ? name
			: name.substring(0, name.length() - extension.length() - 1));
}
 
开发者ID:spring-io,项目名称:artifactory-resource,代码行数:7,代码来源:FileComparator.java

示例8: removePathExtension

import org.springframework.util.StringUtils; //导入方法依赖的package包/类
/**
 * Removes any path extension from the {@link HttpServletRequest#getRequestURI()
 * requestURI}. This method must be invoked before any calls to {@link #path(String)}
 * or {@link #pathSegment(String...)}.
 * <pre>
 *  // GET http://foo.com/rest/books/6.json
 *
 *  YourServletUriComponentsBuilder builder = YourServletUriComponentsBuilder.fromRequestUri(this.request);
 *  String ext = builder.removePathExtension();
 *  String uri = builder.path("/pages/1.{ext}").buildAndExpand(ext).toUriString();
 *
 *  assertEquals("http://foo.com/rest/books/6/pages/1.json", result);
 * </pre>
 * @return the removed path extension for possible re-use, or {@code null}
 * @since 4.0
 */
public String removePathExtension() {
    String extension = null;
    if (this.servletRequestURI != null) {
        String filename = WebUtils.extractFullFilenameFromUrlPath(this.servletRequestURI);
        extension = StringUtils.getFilenameExtension(filename);
        if (!StringUtils.isEmpty(extension)) {
            int end = this.servletRequestURI.length() - extension.length() + 1;
            replacePath(this.servletRequestURI.substring(0, end));
        }
        this.servletRequestURI = null;
    }
    return extension;
}
 
开发者ID:jaschenk,项目名称:Your-Microservice,代码行数:30,代码来源:YourServletUriComponentsBuilder.java


注:本文中的org.springframework.util.StringUtils.getFilenameExtension方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。