本文整理了Java中org.apache.maven.shared.utils.io.FileUtils.extension()
方法的一些代码示例,展示了FileUtils.extension()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。FileUtils.extension()
方法的具体详情如下:
包路径:org.apache.maven.shared.utils.io.FileUtils
类名称: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.apache.maven.shared/maven-shared-utils
/**
* Get extension from filename.
* ie
* <pre>
* foo.txt --> "txt"
* a\b\c.jpg --> "jpg"
* a\b\c --> ""
* </pre>
*
* @param filename the path of the file
* @return the extension of filename or "" if none
*/
@Nonnull public static String getExtension( @Nonnull final String filename )
{
return extension( filename );
}
代码示例来源:origin: org.apache.maven.shared/maven-shared-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
* ("") is matched for.
*/
private static boolean isValidFile( @Nonnull String file, @Nonnull String... extensions )
{
String extension = extension( file );
// 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.apache.maven.shared/maven-script-interpreter
/**
* Determines the script interpreter for the specified script file by looking at its file extension. In this
* context, file extensions are considered case-insensitive. For backward compatibility with plugin versions 1.2-,
* the BeanShell interpreter will be used for any unrecognized extension.
*
* @param scriptFile The script file for which to determine an interpreter, must not be <code>null</code>.
* @return The script interpreter for the file, never <code>null</code>.
*/
private ScriptInterpreter getInterpreter( File scriptFile )
{
String ext = FileUtils.extension( scriptFile.getName() ).toLowerCase( Locale.ENGLISH );
ScriptInterpreter interpreter = scriptInterpreters.get( ext );
if ( interpreter == null )
{
interpreter = scriptInterpreters.get( "bsh" );
}
return interpreter;
}
代码示例来源:origin: org.apache.maven.shared/maven-shared-utils
/**
* Remove extension from filename.
* ie
* <pre>
* foo.txt --> foo
* a\b\c.jpg --> a\b\c
* a\b\c --> a\b\c
* </pre>
*
* @param filename the path of the file
* @return the filename minus extension
*/
@Nonnull public static String removeExtension( @Nonnull 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: org.apache.maven.shared/maven-script-interpreter
+ FileUtils.extension( scriptFile.getAbsolutePath() ) );
代码示例来源:origin: org.apache.maven.shared/maven-filtering
/** {@inheritDoc} */
public boolean filteredFileExtension( String fileName, List<String> userNonFilteredFileExtensions )
{
List<String> nonFilteredFileExtensions = new ArrayList<String>( getDefaultNonFilteredFileExtensions() );
if ( userNonFilteredFileExtensions != null )
{
nonFilteredFileExtensions.addAll( userNonFilteredFileExtensions );
}
boolean filteredFileExtension =
!nonFilteredFileExtensions.contains( StringUtils.lowerCase( FileUtils.extension( fileName ) ) );
if ( getLogger().isDebugEnabled() )
{
getLogger().debug( "file " + fileName + " has a" + ( filteredFileExtension ? " " : " non " )
+ "filtered file extension" );
}
return filteredFileExtension;
}
内容来源于网络,如有侵权,请联系作者删除!