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

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

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

FileUtils.extension介绍

[英]Returns the extension portion of a file specification string. This everything after the last dot '.' in the filename (NOT including the dot).
[中]返回文件规范字符串的扩展名部分。这是最后一点之后的所有内容。”在文件名中(不包括点)。

代码示例

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

/**
 * Get extension from filename. ie
 * 
 * <pre>
 * foo.txt    --&gt; "txt"
 * a\b\c.jpg  --&gt; "jpg"
 * a\b\c      --&gt; ""
 * </pre>
 *
 * @param filename the path of the file
 * @return the extension of filename or "" if none
 */
public static String getExtension( final String filename )
{
  return extension( filename );
}

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

/**
 * Checks to see if a file is of a particular type(s). Note that if the file does not have an extension, an empty
 * string (&quot;&quot;) is matched for.
 */
private static boolean isValidFile( String file, String[] extensions )
{
  String extension = extension( file );
  if ( extension == null )
  {
    extension = "";
  }
  // ok.. now that we have the "extension" go through the current know
  // excepted extensions and determine if this one is OK.
  for ( String extension1 : extensions )
  {
    if ( extension1.equals( extension ) )
    {
      return true;
    }
  }
  return false;
}

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

/**
 * Returns the filename portion of a file specification string. Matches the equally named unix command.
 *
 * @param filename the file path
 * @return The filename string without extension.
 */
public static String basename( String filename )
{
  return basename( filename, extension( filename ) );
}

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

/**
 * Remove extension from filename. ie
 * 
 * <pre>
 * foo.txt    --&gt; foo
 * a\b\c.jpg  --&gt; a\b\c
 * a\b\c      --&gt; a\b\c
 * </pre>
 *
 * @param filename the path of the file
 * @return the filename minus extension
 */
public static String removeExtension( final String filename )
{
  String ext = extension( filename );
  if ( "".equals( ext ) )
  {
    return filename;
  }
  final int index = filename.lastIndexOf( ext ) - 1;
  return filename.substring( 0, index );
}

代码示例来源:origin: diffplug/spotless

private static String tmpOutputFileName(String path) {
    String extension = FileUtils.extension(path);
    return TMP_RESOURCE_FILE_PREFIX + UUID.randomUUID() + '.' + extension;
  }
}

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

/**
 * Get extension from filename.
 * ie
 * <pre>
 * foo.txt    --> "txt"
 * a\b\c.jpg --> "jpg"
 * a\b\c     --> ""
 * </pre>
 *
 * @param filename the filename
 * @return the extension of filename or "" if none
 */
public static String getExtension( final String filename )
{
  return extension(filename);
}

代码示例来源:origin: org.sonatype.maven.archetype/archetype-common

private Set<String> getExtensions(List<String> files) {
  Set<String> extensions = new HashSet<String>();
  for (String file : files) {
    extensions.add(FileUtils.extension(file));
  }
  return extensions;
}

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

private Set<String> getExtensions( List<String> files )
{
  Set<String> extensions = new HashSet<String>();
  for ( String file : files )
  {
    extensions.add( FileUtils.extension( file ) );
  }
  return extensions;
}

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

/**
 * Checks to see if a file is of a particular type(s).
 * Note that if the file does not have an extension, an empty string
 * (&quot;&quot;) is matched for.
 */
private static boolean isValidFile( String file, String[] extensions )
{
  String extension = extension( file );
  if ( extension == null )
  {
    extension = "";
  }
  //ok.. now that we have the "extension" go through the current know
  //excepted extensions and determine if this one is OK.
  for ( int i = 0; i < extensions.length; ++i )
  {
    if ( extensions[i].equals( extension ) )
    {
      return true;
    }
  }
  return false;
}

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

/**
 * Returns the filename portion of a file specification string.
 * Matches the equally named unix command.
 *
 * @return The filename string without extension.
 */
public static String basename( String filename )
{
  return basename( filename, extension( filename ) );
}

代码示例来源:origin: org.codehaus.groovy.maven.runtime/gmaven-runtime-support

public String getScriptName() {
    try {
      // TODO: Use URL.toURI() once Java 5 is the base platform
      File file = new File(new URI(url.toString()).getPath());
      return FileUtils.basename(file.getName(), "." + FileUtils.extension(file.getName()));
    }
    catch (URISyntaxException e) {
      throw new RuntimeException("Unable to determine script class name from: " + url, e);
    }
  }
}

代码示例来源:origin: io.ultreia.java4all.eugene/eugene-core

protected File getAssociatedResource(File file) throws IOException {
  String extension = "." + FileUtils.extension(file.getName());
  String path = file.getAbsolutePath();
  String filename = StringUtils.substring(path, 0, -extension.length()).concat(".properties");
  if (log.isDebugEnabled()) {
    log.info("path of file : " + path);
    log.info("path of resource : " + filename);
  }
  File propertiesFile = new File(filename);
  if (!propertiesFile.exists()) {
    propertiesFile = null;
  }
  return propertiesFile;
}

代码示例来源:origin: gradle.plugin.nl.javadude.gradle.plugins/license-gradle-plugin

private Document getWrapper(File file, String encoding) {
  String headerType = mapping.get(extension(file.getName()).toLowerCase());
  if (headerType == null) {
    headerType = mapping.get("");
  } else {
    headerType = headerType.toLowerCase();
  }
  return new Document(file, definitions.get(headerType), encoding, keywords, documentPropertiesLoader);
}

代码示例来源:origin: org.codehaus.gmaven.runtime/gmaven-runtime-support

public String getScriptName() {
    try {
      // TODO: Use URL.toURI() once Java 5 is the base platform
      File file = new File(new URI(url.toString()).getPath());
      return FileUtils.basename(file.getName(), "." + FileUtils.extension(file.getName()));
    }
    catch (URISyntaxException e) {
      throw new RuntimeException("Unable to determine script class name from: " + url, e);
    }
  }
}

代码示例来源:origin: gradle.plugin.com.hierynomus.gradle.plugins/license-gradle-plugin

private Document getWrapper(File file, String encoding) {
  String headerType = mapping.get(extension(file.getName()).toLowerCase());
  if (headerType == null) {
    headerType = mapping.get("");
  } else {
    headerType = headerType.toLowerCase();
  }
  return new Document(file, definitions.get(headerType), encoding, keywords, documentPropertiesLoader);
}

代码示例来源:origin: com.mycila.maven-license-plugin/maven-license-plugin

private Document getWrapper(String file, String encoding) {
    String headerType = mapping.get(extension(file).toLowerCase());
    if (headerType == null) {
      headerType = mapping.get("");
    } else {
      headerType = headerType.toLowerCase();
    }
    return new Document(new File(basedir, file), definitions.get(headerType), encoding, keywords);
  }
}

代码示例来源:origin: trautonen/coveralls-maven-plugin

protected String getFileName(final String sourceFile) {
  String extension = FileUtils.extension(sourceFile);
  String[] matchingExtensionFiles = scanFor(extension);
  for (String matchingExtensionFile : matchingExtensionFiles) {
    if (SelectorUtils.matchPath("**/" + sourceFile, matchingExtensionFile, true)) {
      return matchingExtensionFile;
    }
  }
  return sourceFile;
}

代码示例来源:origin: org.eluder.coveralls/coveralls-maven-plugin

protected String getFileName(final String sourceFile) {
  String extension = FileUtils.extension(sourceFile);
  String[] matchingExtensionFiles = scanFor(extension);
  for (String matchingExtensionFile : matchingExtensionFiles) {
    if (SelectorUtils.matchPath("**/" + sourceFile, matchingExtensionFile, true)) {
      return matchingExtensionFile;
    }
  }
  return sourceFile;
}

代码示例来源:origin: org.apache.maven.doxia/doxia-module-docbook-simple

/** {@inheritDoc} */
public void figureGraphics( String name )
{
  String format = FileUtils.extension( name ).toUpperCase( Locale.ENGLISH );
  writeStartTag( SimplifiedDocbookMarkup.IMAGEOBJECT_TAG );
  MutableAttributeSet att = new SimpleAttributeSet();
  att.addAttribute( SimplifiedDocbookMarkup.FORMAT_ATTRIBUTE, format );
  att.addAttribute( SimplifiedDocbookMarkup.FILEREF_ATTRIBUTE, HtmlTools.escapeHTML( name, true ) );
  writeSimpleTag( SimplifiedDocbookMarkup.IMAGEDATA_TAG, att );
  writeEndTag( SimplifiedDocbookMarkup.IMAGEOBJECT_TAG );
}

代码示例来源:origin: net.jangaroo/ext-xml

private void scan(final File dir) throws IOException {
  FileSet srcFiles = new FileSet();
  srcFiles.setDirectory(dir.getAbsolutePath());
  srcFiles.addInclude("**/*." + ComponentType.JavaScript.getExtension());
  srcFiles.addExclude("**/*-more." + ComponentType.JavaScript.getExtension()); // exclude special Ext JS files
  srcFiles.addInclude("**/*." + ComponentType.ActionScript.getExtension());
  srcFiles.addInclude("**/*." + ComponentType.EXML.getExtension());
  for (String srcFileRelativePath : new FileSetManager().getIncludedFiles(srcFiles)) {
   File srcFile = new File(dir, srcFileRelativePath);
   Log.setCurrentFile(srcFile);
   
   ComponentType type = ComponentType.from(FileUtils.extension(srcFile.getName()));

   if (ComponentType.EXML.equals(type)) {
    ExmlComponentSrcFileScanner.scan(componentSuite, srcFile, type);
   } else {
    //parse AS3 or JS files
    ExtComponentSrcFileScanner.scan(componentSuite, srcFile, type);
   }
  }
 }
}

相关文章