當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。