org.codehaus.plexus.util.FileUtils.removePath()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(2.9k)|赞(0)|评价(0)|浏览(100)

本文整理了Java中org.codehaus.plexus.util.FileUtils.removePath()方法的一些代码示例,展示了FileUtils.removePath()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。FileUtils.removePath()方法的具体详情如下:
包路径:org.codehaus.plexus.util.FileUtils
类名称:FileUtils
方法名:removePath

FileUtils.removePath介绍

[英]Remove path from filename. Equivalent to the unix command basename ie.

a/b/c.txt --> c.txt 
a.txt     --> a.txt

[中]从文件名中删除路径。相当于unix命令basenameie.

a/b/c.txt --> c.txt 
a.txt     --> a.txt

代码示例

代码示例来源:origin: org.codehaus.plexus/plexus-utils

/**
 * Remove path from filename. Equivalent to the unix command <code>basename</code> ie.
 * 
 * <pre>
 * a/b/c.txt --&gt; c.txt
 * a.txt     --&gt; a.txt
 * </pre>
 *
 * @param filepath the path of the file
 * @return the filename minus path
 */
public static String removePath( final String filepath )
{
  return removePath( filepath, File.separatorChar );
}

代码示例来源:origin: org.apache.servicemix.kernel.gshell/org.apache.servicemix.kernel.gshell.core

/**
 * Remove path from filename. Equivalent to the unix command <code>basename</code>
 * ie.
 * <pre>
 * a/b/c.txt --> c.txt
 * a.txt     --> a.txt
 * </pre>
 *
 * @param filepath the filepath
 * @return the filename minus path
 */
public static String removePath( final String filepath )
{
  return removePath( 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;
  }
}

代码示例来源:origin: apache/maven-wagon

File scmFile = new File( newCheckoutDirectory, isDirectory ? "" : FileUtils.removePath( targetName, '/' ) );

相关文章