本文整理了Java中org.codehaus.plexus.util.FileUtils.getPath()
方法的一些代码示例,展示了FileUtils.getPath()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。FileUtils.getPath()
方法的具体详情如下:
包路径:org.codehaus.plexus.util.FileUtils
类名称:FileUtils
方法名:getPath
[英]Get path from filename. Roughly equivalent to the unix command dirname
. ie.
a/b/c.txt --> a/b
a.txt --> ""
[中]从文件名获取路径。大致相当于unix命令dirname
。即
a/b/c.txt --> a/b
a.txt --> ""
代码示例来源:origin: org.codehaus.plexus/plexus-utils
/**
* Get path from filename. Roughly equivalent to the unix command <code>dirname</code>. ie.
*
* <pre>
* a/b/c.txt --> a/b
* a.txt --> ""
* </pre>
*
* @param filepath the filepath
* @return the filename minus path
*/
public static String getPath( final String filepath )
{
return getPath( filepath, File.separatorChar );
}
代码示例来源:origin: apache/maven-wagon
private String getDirname( String resourceName )
{
return FileUtils.getPath( resourceName, '/' );
}
}
代码示例来源:origin: org.apache.servicemix.kernel.gshell/org.apache.servicemix.kernel.gshell.core
/**
* Get path from filename. Roughly equivalent to the unix command <code>dirname</code>.
* ie.
* <pre>
* a/b/c.txt --> a/b
* a.txt --> ""
* </pre>
*
* @param filepath the filepath
* @return the filename minus path
*/
public static String getPath( final String filepath )
{
return getPath( filepath, File.separatorChar );
}
代码示例来源:origin: org.sonatype.nexus/nexus-proxy
/**
* Gets the file from base.
*
* @param uid the uid
* @return the file from base
*/
protected File getFileFromBase( final RepositoryItemUid uid, final File workingDirectory )
throws IOException
{
final File repoBase = new File( workingDirectory, uid.getRepository().getId() );
File result = null;
String path = FileUtils.getPath( uid.getPath() );
String name = FileUtils.removePath( uid.getPath() );
result = new File( repoBase, path + "/" + name );
// to be foolproof
// 2007.11.09. - Believe or not, Nexus deleted my whole USB rack! (cstamas)
// ok, now you may laugh :)
if ( !result.getAbsolutePath().startsWith( workingDirectory.getAbsolutePath() ) )
{
throw new IOException( "FileFromBase evaluated directory wrongly! baseDir="
+ workingDirectory.getAbsolutePath() + ", target=" + result.getAbsolutePath() );
}
else
{
return result;
}
}
代码示例来源:origin: org.sonatype.nexus/nexus-proxy
/**
* Gets the file from base.
*
* @param uid the uid
* @return the file from base
*/
protected File getFileFromBase( final RepositoryItemUid uid )
throws IOException
{
final File repoBase = new File( getWorkingDirectory(), uid.getRepository().getId() );
File result = null;
String path = FileUtils.getPath( uid.getPath() );
String name = FileUtils.removePath( uid.getPath() );
result = new File( repoBase, path + "/" + name );
// to be foolproof
// 2007.11.09. - Believe or not, Nexus deleted my whole USB rack! (cstamas)
// ok, now you may laugh :)
if ( !result.getAbsolutePath().startsWith( getWorkingDirectory().getAbsolutePath() ) )
{
throw new IOException( "FileFromBase evaluated directory wrongly! baseDir="
+ getWorkingDirectory().getAbsolutePath() + ", target=" + result.getAbsolutePath() );
}
else
{
return result;
}
}
内容来源于网络,如有侵权,请联系作者删除!