本文整理了Java中org.codehaus.plexus.util.FileUtils.getExtension()
方法的一些代码示例,展示了FileUtils.getExtension()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。FileUtils.getExtension()
方法的具体详情如下:
包路径:org.codehaus.plexus.util.FileUtils
类名称:FileUtils
方法名:getExtension
[英]Get extension from filename. ie
foo.txt --> "txt"
a\b\c.jpg --> "jpg"
a\b\c --> ""
[中]从文件名获取扩展名。ie
foo.txt --> "txt"
a\b\c.jpg --> "jpg"
a\b\c --> ""
代码示例来源:origin: eirslett/frontend-maven-plugin
if ("msi".equals(FileUtils.getExtension(archiveFile.getAbsolutePath()))) {
String command = "msiexec /a " + archiveFile.getAbsolutePath() + " /qn TARGETDIR=\""
+ destinationDirectory + "\"";
"Unexpected interruption of while waiting for extraction process", e);
} else if ("zip".equals(FileUtils.getExtension(archiveFile.getAbsolutePath()))) {
ZipFile zipFile = new ZipFile(archiveFile);
try {
代码示例来源:origin: org.codehaus.plexus/plexus-archiver
private static @Nonnull
String getFileExtention( @Nonnull File file )
{
String path = file.getAbsolutePath();
String archiveExt = FileUtils.getExtension( path ).toLowerCase( Locale.ENGLISH );
if ( "gz".equals( archiveExt )
|| "bz2".equals( archiveExt )
|| "xz".equals( archiveExt )
|| "snappy".equals( archiveExt ) )
{
String[] tokens = StringUtils.split( path, "." );
if ( tokens.length > 2 && "tar".equals( tokens[tokens.length - 2].toLowerCase( Locale.ENGLISH ) ) )
{
archiveExt = "tar." + archiveExt;
}
}
return archiveExt;
}
代码示例来源:origin: org.apache.maven.doxia/doxia-doc-renderer
/**
* @param f not null
* @return <code>true</code> if file has a vm extension, <code>false</false> otherwise.
*/
private static boolean isVelocityFile( File f )
{
return FileUtils.getExtension( f.getAbsolutePath() ).toLowerCase( Locale.ENGLISH ).endsWith( "vm" );
}
代码示例来源:origin: org.zkoss.maven/yuicompressor-maven-plugin-zk
protected File gzipIfRequested(File file) throws Exception {
if (!gzip || (file == null) || (!file.exists())) {
return null;
}
if (".gz".equalsIgnoreCase(FileUtils.getExtension(file.getName()))) {
return null;
}
File gzipped = new File(file.getAbsolutePath() + ".gz");
getLog().debug(String.format("create gzip version : %s", gzipped.getName()));
GZIPOutputStream out = null;
FileInputStream in = null;
try {
out = new GZIPOutputStream(new FileOutputStream(gzipped));
in = new FileInputStream(file);
IOUtil.copy(in, out);
} finally {
IOUtil.close(in);
IOUtil.close(out);
}
return gzipped;
}
代码示例来源:origin: org.apache.maven.plugins/maven-gpg-plugin
private void initProperties()
throws MojoExecutionException
{
// Process the supplied POM (if there is one)
if ( pomFile != null )
{
generatePom = false;
Model model = readModel( pomFile );
processModel( model );
}
if ( packaging == null && file != null )
{
packaging = FileUtils.getExtension( file.getName() );
}
}
代码示例来源:origin: org.jboss.windup.org.apache.maven.indexer/indexer-core
private String getExtension( File artifact, Gav gav )
{
if ( gav != null && StringUtils.isNotBlank( gav.getExtension() ) )
{
return gav.getExtension();
}
// last resort, the extension of the file
String artifactFileName = artifact.getName().toLowerCase();
// tar.gz? and other "special" combinations
if ( artifactFileName.endsWith( "tar.gz" ) )
{
return "tar.gz";
}
else if ( artifactFileName.equals( "tar.bz2" ) )
{
return "tar.bz2";
}
// get the part after the last dot
return FileUtils.getExtension( artifactFileName );
}
代码示例来源:origin: apache/maven-indexer
private String getExtension( File artifact, Gav gav )
{
if ( gav != null && StringUtils.isNotBlank( gav.getExtension() ) )
{
return gav.getExtension();
}
// last resort, the extension of the file
String artifactFileName = artifact.getName().toLowerCase();
// tar.gz? and other "special" combinations
if ( artifactFileName.endsWith( "tar.gz" ) )
{
return "tar.gz";
}
else if ( artifactFileName.equals( "tar.bz2" ) )
{
return "tar.bz2";
}
// get the part after the last dot
return FileUtils.getExtension( artifactFileName );
}
代码示例来源:origin: org.apache.maven.indexer/indexer-core
private String getExtension( File artifact, Gav gav )
{
if ( gav != null && StringUtils.isNotBlank( gav.getExtension() ) )
{
return gav.getExtension();
}
// last resort, the extension of the file
String artifactFileName = artifact.getName().toLowerCase();
// tar.gz? and other "special" combinations
if ( artifactFileName.endsWith( "tar.gz" ) )
{
return "tar.gz";
}
else if ( artifactFileName.equals( "tar.bz2" ) )
{
return "tar.bz2";
}
// get the part after the last dot
return FileUtils.getExtension( artifactFileName );
}
代码示例来源:origin: org.sonatype.nexus/nexus-indexer
private String getExtension( File artifact, Gav gav )
{
if ( gav != null && StringUtils.isNotBlank( gav.getExtension() ) )
{
return gav.getExtension();
}
// last resort, the extension of the file
String artifactFileName = artifact.getName().toLowerCase();
// tar.gz? and other "special" combinations
if ( artifactFileName.endsWith( "tar.gz" ) )
{
return "tar.gz";
}
else if ( artifactFileName.equals( "tar.bz2" ) )
{
return "tar.bz2";
}
// get the part after the last dot
return FileUtils.getExtension( artifactFileName );
}
代码示例来源:origin: jenkinsci/maven-hpi-plugin
/**
* Unpacks the archive file.
*
* @param file File to be unpacked.
* @param location Location where to put the unpacked files.
*/
private void unpack(File file, File location)
throws MojoExecutionException, NoSuchArchiverException {
String archiveExt = FileUtils.getExtension(file.getAbsolutePath()).toLowerCase();
try {
UnArchiver unArchiver = archiverManager.getUnArchiver(archiveExt);
unArchiver.setSourceFile(file);
unArchiver.setDestDirectory(location);
unArchiver.extract();
}
catch (IOException e) {
throw new MojoExecutionException("Error unpacking file: " + file + "to: " + location, e);
}
catch (ArchiverException e) {
throw new MojoExecutionException("Error unpacking file: " + file + "to: " + location, e);
}
}
代码示例来源:origin: org.codehaus.mojo.natives/maven-native-mingw
String libFileName = (String) iter.next();
String ext = FileUtils.getExtension(libFileName);
String libFileName = (String) iter.next();
String ext = FileUtils.getExtension(libFileName);
代码示例来源:origin: org.codehaus.mojo.natives/maven-native-generic-c
String ext = FileUtils.getExtension( libFileName );
String ext = FileUtils.getExtension( libFileName );
代码示例来源:origin: org.codehaus.mojo/xmlbeans-maven-plugin
String ext = FileUtils.getExtension( schemaName );
if ( !includeFilter.endsWith( ext ) )
String ext = FileUtils.getExtension( nextFile.getName() );
if ( includeFilter.endsWith( ext ) )
代码示例来源:origin: org.apache.maven.plugins/maven-war-plugin
throws MojoExecutionException
String archiveExt = FileUtils.getExtension( file.getAbsolutePath() ).toLowerCase();
代码示例来源:origin: org.apache.maven.plugins/maven-antrun-plugin
/** {@inheritDoc} */
public void execute()
{
if ( file == null )
{
throw new BuildException( "File is a required parameter." );
}
if ( !file.exists() )
{
throw new BuildException( "File does not exist: " + file );
}
if ( this.getProject().getReference( mavenProjectRefId ) == null )
{
throw new BuildException( "Maven project reference not found: " + mavenProjectRefId );
}
if ( type == null )
{
type = FileUtils.getExtension( file.getName() );
}
MavenProject mavenProject = (MavenProject) this.getProject().getReference( mavenProjectRefId );
if ( this.getProject().getReference( mavenProjectHelperRefId ) == null )
{
throw new BuildException( "Maven project helper reference not found: " + mavenProjectHelperRefId );
}
log( "Attaching " + file + " as an attached artifact", Project.MSG_VERBOSE );
MavenProjectHelper projectHelper = (MavenProjectHelper) getProject().getReference( mavenProjectHelperRefId );
projectHelper.attachArtifact( mavenProject, type, classifier, file );
}
代码示例来源:origin: org.codehaus.mojo.natives/maven-native-bcc
if ( !FileUtils.getExtension( fileName ).toLowerCase().equals( "res" ) )
if ( FileUtils.getExtension( fileName ).toLowerCase().equals( "res" ) )
代码示例来源:origin: org.codehaus.mojo.natives/maven-native-api
public List compile( ResourceCompilerConfiguration config, NativeSources[] sources )
throws NativeBuildException
{
File[] sourceFiles = NativeSources.getAllSourceFiles( sources );
config.setIncludePaths( NativeSources.getIncludePaths( sources ) );
config.setSystemIncludePaths( NativeSources.getSystemIncludePaths( sources ) );
List compilerOutputFiles = new ArrayList( sourceFiles.length );
for ( int i = 0; i < sourceFiles.length; ++i )
{
File src = sourceFiles[i];
if ( !"rc".equals( FileUtils.getExtension( src.getPath() ) ) )
{
continue;
}
File outputFile = config.getOutputFile( src );
compilerOutputFiles.add( outputFile );
if ( isResourceFileStaled( src, outputFile, config.getIncludePaths() ) )
{
Commandline cl = getCommandLine( config, src );
EnvUtil.setupCommandlineEnv( cl, config.getEnvFactory() );
CommandLineUtil.execute( cl, this.getLogger() );
}
}
return compilerOutputFiles;
}
代码示例来源:origin: org.codehaus.mojo.natives/maven-native-msvc
if ( "EXE".equalsIgnoreCase( FileUtils.getExtension( config.getInputFile().getPath() ) ) )
else if ( "DLL".equalsIgnoreCase( FileUtils.getExtension( config.getInputFile().getPath() ) ) )
内容来源于网络,如有侵权,请联系作者删除!