本文整理了Java中org.apache.commons.io.FilenameUtils.separatorsToUnix()
方法的一些代码示例,展示了FilenameUtils.separatorsToUnix()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。FilenameUtils.separatorsToUnix()
方法的具体详情如下:
包路径:org.apache.commons.io.FilenameUtils
类名称:FilenameUtils
方法名:separatorsToUnix
[英]Converts all separators to the Unix separator of forward slash.
[中]将所有分隔符转换为正斜杠的Unix分隔符。
代码示例来源:origin: gocd/gocd
public WildcardScanner(File rootPath, String pattern) {
this.rootPath = rootPath;
this.pattern = FilenameUtils.separatorsToUnix(pattern);
}
代码示例来源:origin: gocd/gocd
@Override
public String getDestination() {
return StringUtils.isBlank(destination) ? TEST_OUTPUT_FOLDER : FilenameUtils.separatorsToUnix(destination);
}
}
代码示例来源:origin: gocd/gocd
protected File valueOf(String text) {
if (text == null) {
return null;
}
return new File(FilenameUtils.separatorsToUnix(text));
}
}
代码示例来源:origin: gocd/gocd
public static String subtractPath(File rootPath, File file) {
String fullPath = FilenameUtils.separatorsToUnix(file.getParentFile().getPath());
String basePath = FilenameUtils.separatorsToUnix(rootPath.getPath());
return StringUtils.removeStart(StringUtils.removeStart(fullPath, basePath), "/");
}
代码示例来源:origin: gocd/gocd
@Override
public String getDestination() {
return StringUtils.isBlank(destination) ? DEFAULT_ROOT.getPath() : FilenameUtils.separatorsToUnix(destination);
}
代码示例来源:origin: gocd/gocd
private String removeLeadingSlash(File artifactDest) {
return removeStart(FilenameUtils.separatorsToUnix(artifactDest.getPath()), "/");
}
}
代码示例来源:origin: gocd/gocd
public String arguments() {
ArrayList<String> args = new ArrayList<>();
if (buildFile != null) {
args.add("-f \"" + FilenameUtils.separatorsToUnix(buildFile) + "\"");
}
if (target != null) {
args.add(target);
}
return StringUtils.join(args, " ");
}
代码示例来源:origin: gocd/gocd
public String arguments() {
ArrayList<String> args = new ArrayList<>();
if (buildFile != null) {
args.add("-buildfile:\"" + FilenameUtils.separatorsToUnix(buildFile) + "\"");
}
if (target != null) {
args.add(target);
}
return StringUtils.join(args, " ");
}
代码示例来源:origin: gocd/gocd
public String arguments() {
ArrayList<String> args = new ArrayList<>();
if (buildFile != null) {
args.add("-f \"" + FilenameUtils.separatorsToUnix(buildFile) + "\"");
}
if (target != null) {
args.add(target);
}
return StringUtils.join(args, " ");
}
代码示例来源:origin: gocd/gocd
private String getSrcFilePath(ZipEntry entry) {
String parent = new File(srcFile).getParent();
return FilenameUtils.separatorsToUnix(new File(parent, entry.getName()).getPath());
}
代码示例来源:origin: gocd/gocd
protected String destURL(File rootPath, File file, String src, String dest) {
String trimmedPattern = rtrimStandardrizedWildcardTokens(src);
if (StringUtils.equals(FilenameUtils.separatorsToUnix(trimmedPattern), FilenameUtils.separatorsToUnix(src))) {
return dest;
}
String trimmedPath = removeStart(subtractPath(rootPath, file), FilenameUtils.separatorsToUnix(trimmedPattern));
if (!StringUtils.startsWith(trimmedPath, "/") && StringUtils.isNotEmpty(trimmedPath)) {
trimmedPath = "/" + trimmedPath;
}
return dest + trimmedPath;
}
代码示例来源:origin: gocd/gocd
protected String destinationURL(File rootPath, File file, String src, String dest) {
String trimmedPattern = rtrimStandardrizedWildcardTokens(src);
if (StringUtils.equals(FilenameUtils.separatorsToUnix(trimmedPattern), FilenameUtils.separatorsToUnix(src))) {
return dest;
}
String trimmedPath = removeStart(subtractPath(rootPath, file), FilenameUtils.separatorsToUnix(trimmedPattern));
if (!StringUtils.startsWith(trimmedPath, "/") && StringUtils.isNotEmpty(trimmedPath)) {
trimmedPath = "/" + trimmedPath;
}
return dest + trimmedPath;
}
代码示例来源:origin: gocd/gocd
public String getFullViewPath() {
if (StringUtils.isBlank(assetRoot)) {
return viewPath;
}
int positionOfQueryParamStart = viewPath.indexOf('?');
String viewPathWithoutQueryParams = positionOfQueryParamStart == -1 ? viewPath : viewPath.substring(0, positionOfQueryParamStart);
String queryParams = positionOfQueryParamStart == -1 ? "" : viewPath.substring(positionOfQueryParamStart);
return URI.create(FilenameUtils.separatorsToUnix(Paths.get(assetRoot, viewPathWithoutQueryParams).toString()) + queryParams).normalize().toString();
}
代码示例来源:origin: gocd/gocd
public static String join(File defaultWorkingDir, String actualFileToUse) {
if (actualFileToUse == null) {
LOGGER.trace("Using the default Directory->{}", defaultWorkingDir);
return FilenameUtils.separatorsToUnix(defaultWorkingDir.getPath());
}
return applyBaseDirIfRelativeAndNormalize(defaultWorkingDir, new File(actualFileToUse));
}
代码示例来源:origin: gocd/gocd
private Properties computeChecksumForContentsOfDirectory(File directory, String destPath) throws IOException {
Collection<File> fileStructure = FileUtils.listFiles(directory, null, true);
Properties checksumProperties = new Properties();
for (File file : fileStructure) {
String filePath = removeStart(file.getAbsolutePath(), directory.getParentFile().getAbsolutePath());
try (FileInputStream inputStream = new FileInputStream(file)) {
checksumProperties.setProperty(getEffectiveFileName(destPath, FilenameUtils.separatorsToUnix(filePath)), md5Hex(inputStream));
}
}
return checksumProperties;
}
代码示例来源:origin: gocd/gocd
private Properties computeChecksumForContentsOfDirectory(File directory, String destPath) throws IOException {
Collection<File> fileStructure = FileUtils.listFiles(directory, null, true);
Properties checksumProperties = new Properties();
for (File file : fileStructure) {
String filePath = removeStart(file.getAbsolutePath(), directory.getParentFile().getAbsolutePath());
try (FileInputStream inputStream = new FileInputStream(file)) {
checksumProperties.setProperty(getEffectiveFileName(destPath, FilenameUtils.separatorsToUnix(filePath)), md5Hex(inputStream));
}
}
return checksumProperties;
}
代码示例来源:origin: gocd/gocd
public File cachedFile(ArtifactFolder artifactFolder) {
File root = artifactsDirHolder.getArtifactsDir();
String relativize = FilenameUtils.separatorsToUnix(artifactFolder.getRootFolder().getPath()).replaceFirst(FilenameUtils.separatorsToUnix(root.getPath()), CACHE_ARTIFACTS_FOLDER);
return new File(root, removeTrailingSlash(relativize) + ".zip");
}
}
代码示例来源:origin: commons-io/commons-io
/**
* Converts all separators to the system separator.
*
* @param path the path to be changed, null ignored
* @return the updated path
*/
public static String separatorsToSystem(final String path) {
if (path == null) {
return null;
}
if (isSystemWindows()) {
return separatorsToWindows(path);
} else {
return separatorsToUnix(path);
}
}
代码示例来源:origin: Alluxio/alluxio
/**
* Checks and normalizes the given path.
*
* @param path The path to clean up
* @return a normalized version of the path, with single separators between path components and
* dot components resolved
* @throws InvalidPathException if the path is invalid
*/
public static String cleanPath(String path) throws InvalidPathException {
validatePath(path);
return FilenameUtils.separatorsToUnix(FilenameUtils.normalizeNoEndSeparator(path));
}
代码示例来源:origin: commons-io/commons-io
@Test
public void testSeparatorsToUnix() {
assertEquals(null, FilenameUtils.separatorsToUnix(null));
assertEquals("/a/b/c", FilenameUtils.separatorsToUnix("/a/b/c"));
assertEquals("/a/b/c.txt", FilenameUtils.separatorsToUnix("/a/b/c.txt"));
assertEquals("/a/b/c", FilenameUtils.separatorsToUnix("/a/b\\c"));
assertEquals("/a/b/c", FilenameUtils.separatorsToUnix("\\a\\b\\c"));
assertEquals("D:/a/b/c", FilenameUtils.separatorsToUnix("D:\\a\\b\\c"));
}
内容来源于网络,如有侵权,请联系作者删除!