本文整理了Java中org.apache.commons.io.FilenameUtils.getPathNoEndSeparator()
方法的一些代码示例,展示了FilenameUtils.getPathNoEndSeparator()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。FilenameUtils.getPathNoEndSeparator()
方法的具体详情如下:
包路径:org.apache.commons.io.FilenameUtils
类名称:FilenameUtils
方法名:getPathNoEndSeparator
[英]Gets the path from a full filename, which excludes the prefix, and also excluding the final directory separator.
This method will handle a file in either Unix or Windows format. The method is entirely text based, and returns the text before the last forward or backslash.
C:\a\b\c.txt --> a\b
~/a/b/c.txt --> a/b
a.txt --> ""
a/b/c --> a/b
a/b/c/ --> a/b/c
The output will be the same irrespective of the machine that the code is running on.
This method drops the prefix from the result. See #getFullPathNoEndSeparator(String) for the method that retains the prefix.
[中]从完整文件名获取路径,该文件名不包括前缀,也不包括最终的目录分隔符。
此方法将处理Unix或Windows格式的文件。该方法完全基于文本,并返回最后一个正斜杠或反斜杠之前的文本。
C:\a\b\c.txt --> a\b
~/a/b/c.txt --> a/b
a.txt --> ""
a/b/c --> a/b
a/b/c/ --> a/b/c
无论代码在哪台机器上运行,输出都是相同的。
此方法从结果中删除前缀。有关保留前缀的方法,请参见#getFullPathNoEndSeparator(String)。
代码示例来源:origin: jooby-project/jooby
public LessStrSource(final String content, final String name) {
super(content, name);
this.path = spath(FilenameUtils.getPathNoEndSeparator(name));
}
代码示例来源:origin: commons-io/commons-io
@Test
public void testGetPathNoEndSeparator_with_null_byte() {
try {
assertEquals("a/b", FilenameUtils.getPathNoEndSeparator("~user/a\u0000/b/c.txt"));
} catch (final IllegalArgumentException ignore) {
}
}
代码示例来源:origin: commons-io/commons-io
assertEquals(null, FilenameUtils.getPath(null));
assertEquals("", FilenameUtils.getPath("noseperator.inthispath"));
assertEquals("", FilenameUtils.getPathNoEndSeparator("/noseperator.inthispath"));
assertEquals("", FilenameUtils.getPathNoEndSeparator("\\noseperator.inthispath"));
assertEquals("a/b", FilenameUtils.getPathNoEndSeparator("a/b/c.txt"));
assertEquals("a/b", FilenameUtils.getPathNoEndSeparator("a/b/c"));
assertEquals("a/b/c", FilenameUtils.getPathNoEndSeparator("a/b/c/"));
assertEquals("a\\b", FilenameUtils.getPathNoEndSeparator("a\\b\\c"));
assertEquals(null, FilenameUtils.getPathNoEndSeparator(":"));
assertEquals(null, FilenameUtils.getPathNoEndSeparator("1:/a/b/c.txt"));
assertEquals(null, FilenameUtils.getPathNoEndSeparator("1:"));
assertEquals(null, FilenameUtils.getPathNoEndSeparator("1:a"));
assertEquals(null, FilenameUtils.getPathNoEndSeparator("///a/b/c.txt"));
assertEquals(null, FilenameUtils.getPathNoEndSeparator("//a"));
assertEquals("", FilenameUtils.getPathNoEndSeparator(""));
assertEquals("", FilenameUtils.getPathNoEndSeparator("C:"));
assertEquals("", FilenameUtils.getPathNoEndSeparator("C:/"));
assertEquals("", FilenameUtils.getPathNoEndSeparator("//server/"));
assertEquals("", FilenameUtils.getPathNoEndSeparator("~"));
assertEquals("", FilenameUtils.getPathNoEndSeparator("~/"));
assertEquals("", FilenameUtils.getPathNoEndSeparator("~user"));
assertEquals("", FilenameUtils.getPathNoEndSeparator("~user/"));
assertEquals("a/b", FilenameUtils.getPathNoEndSeparator("a/b/c.txt"));
assertEquals("a/b", FilenameUtils.getPathNoEndSeparator("/a/b/c.txt"));
assertEquals("", FilenameUtils.getPathNoEndSeparator("C:a"));
assertEquals("a/b", FilenameUtils.getPathNoEndSeparator("C:a/b/c.txt"));
代码示例来源:origin: geotools/geotools
private static File getAlternativeFile(String path, boolean removeExtension) {
String basePath = FilenameUtils.getPathNoEndSeparator(path);
String name =
removeExtension ? FilenameUtils.getBaseName(path) : FilenameUtils.getName(path);
String alternativePath = basePath + File.separatorChar + name;
return new File(FOOTPRINTS_DATA_DIR, alternativePath);
}
代码示例来源:origin: pentaho/pentaho-platform
public SchedulerOutputPathResolver( final String outputPathPattern, final String actionUser ) {
this.jobName = FilenameUtils.getBaseName( outputPathPattern );
this.outputDirectory = FilenameUtils.getPathNoEndSeparator( outputPathPattern );
this.actionUser = actionUser;
}
代码示例来源:origin: pentaho/pentaho-platform
/**
* Gets the path from a full filename, which excludes the prefix, and also excluding the final directory separator.
* <p/>
* The method is entirely text based, and returns the text before the last forward or backslash.
*
* <pre>
* a.txt --> ""
* a/b/c --> a/b
* a/b/c/ --> a/b/c
* /a.txt --> ""
* /a/b/c --> a/b
* /a/b/c/ --> a/b/c
* </pre>
* <p/>
* This method drops the prefix from the result. See {@link #getFullPathNoEndSeparator(String)} for the method that
* retains the prefix.
*
* @param filename
* the filename to query, null returns null
* @return the path of the file, an empty string if none exists, null if invalid
*/
public static String getPathNoEndSeparator( final String filename ) {
return FilenameUtils.getPathNoEndSeparator( filename );
}
代码示例来源:origin: org.apache.flex.flexjs.compiler/compiler
/**
* Generates a URI prefix for a file private namespace in the specified
* {@link ASFileScope}.
*
* @param baseName The basename of the private namespace
* @param fileScope The {@link ASFileScope} which contains the file
* private namespace for which a URI prefix is to be generated.
* @return The URI prefix for the file private namespace of the
* specified {@link ASFileScope}.
* @see #generateURI(INamespaceReference, IASScope, String)
*/
private static String generateQualifierPrefixStringForFilePrivate(String baseName, ASFileScope fileScope)
{
String sourcePath = fileScope.getContainingPath();
String dirName = FilenameUtils.getPathNoEndSeparator(sourcePath);
String md5String = StringEncoder.stringToMD5String(dirName);
return FilenameUtils.getName(baseName) + "$" + md5String;
}
代码示例来源:origin: org.apache.royale.compiler/compiler
/**
* Generates a URI prefix for a file private namespace in the specified
* {@link ASFileScope}.
*
* @param baseName The basename of the private namespace
* @param fileScope The {@link ASFileScope} which contains the file
* private namespace for which a URI prefix is to be generated.
* @return The URI prefix for the file private namespace of the
* specified {@link ASFileScope}.
* @see #generateURI(INamespaceReference, IASScope, String)
*/
private static String generateQualifierPrefixStringForFilePrivate(String baseName, ASFileScope fileScope)
{
String sourcePath = fileScope.getContainingPath();
String dirName = FilenameUtils.getPathNoEndSeparator(sourcePath);
String md5String = StringEncoder.stringToMD5String(dirName);
return FilenameUtils.getName(baseName) + "$" + md5String;
}
代码示例来源:origin: com.github.mike10004/config-doclet-tests-common
JarFile jarFile = conn.getJarFile();
String pomEntryName = conn.getEntryName();
String pomParentDir = FilenameUtils.getPathNoEndSeparator(pomEntryName) + "/";
Predicate<? super JarEntry> filter = entry -> {
return entry.getName().startsWith(pomParentDir);
代码示例来源:origin: apache/royale-compiler
/**
* Generates a URI prefix for a file private namespace in the specified
* {@link ASFileScope}.
*
* @param baseName The basename of the private namespace
* @param fileScope The {@link ASFileScope} which contains the file
* private namespace for which a URI prefix is to be generated.
* @return The URI prefix for the file private namespace of the
* specified {@link ASFileScope}.
* @see #generateURI(INamespaceReference, IASScope, String)
*/
private static String generateQualifierPrefixStringForFilePrivate(String baseName, ASFileScope fileScope)
{
String sourcePath = fileScope.getContainingPath();
String dirName = FilenameUtils.getPathNoEndSeparator(sourcePath);
String md5String = StringEncoder.stringToMD5String(dirName);
return FilenameUtils.getName(baseName) + "$" + md5String;
}
代码示例来源:origin: org.geoserver.web/gs-web-core
FilenameUtils.getPathNoEndSeparator(path)
+ "/"
+ FilenameUtils.getBaseName(path);
代码示例来源:origin: org.smartrplace.apps/smartrplace-util-proposed
ZipOutputStream out = null;
try {
String destDir = FilenameUtils.getPathNoEndSeparator(destination.toString());
Path f = Paths.get(destDir);
if(Files.notExists(f)) {
代码示例来源:origin: org.jfrog.buildinfo/build-info-client
String relativeParentPath = FilenameUtils.getPathNoEndSeparator(relativePath);
itemPathBuilder.append(relativeParentPath);
addedRelativeParent = true;
代码示例来源:origin: org.apache.stanbol/org.apache.stanbol.entityhub.indexing.core
FilenameUtils.getPathNoEndSeparator(entryName));
if(targetFolder.exists() || targetFolder.mkdirs()){
File outFile = new File(targetFolder,
代码示例来源:origin: apache/stanbol
FilenameUtils.getPathNoEndSeparator(entryName));
if(targetFolder.exists() || targetFolder.mkdirs()){
File outFile = new File(targetFolder,
代码示例来源:origin: org.geotools/gt-imagemosaic
String typeName = FilenameUtils.getBaseName(FilenameUtils.getPathNoEndSeparator(this.parentLocation));
代码示例来源:origin: gradle.plugin.org.echocat.gradle.plugins/gradle-golang-plugin
final String base = golang.getPackageName();
for (final String file : scanner.getIncludedFiles()) {
final String path = FilenameUtils.getPathNoEndSeparator(file).replace(File.separatorChar, '/');
if (isNotEmpty(path)) {
result.add(base + "/" + path);
代码示例来源:origin: CampagneLaboratory/variationanalysis
inputBasename="/"+inputBasename;
if (FilenameUtils.getPathNoEndSeparator(filename).equals("")){
inputBasename="./"+inputBasename;
代码示例来源:origin: echocat/gradle-golang-plugin
final String base = golang.getPackageName();
for (final String file : scanner.getIncludedFiles()) {
final String path = FilenameUtils.getPathNoEndSeparator(file).replace(File.separatorChar, '/');
final String packageName = isNotEmpty(path) ? base + "/" + path : base;
for (final Path gopath : build.getGopathSourceRoot()) {
内容来源于网络,如有侵权,请联系作者删除!