本文整理汇总了Java中org.codehaus.plexus.archiver.ResourceIterator类的典型用法代码示例。如果您正苦于以下问题:Java ResourceIterator类的具体用法?Java ResourceIterator怎么用?Java ResourceIterator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ResourceIterator类属于org.codehaus.plexus.archiver包,在下文中一共展示了ResourceIterator类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: checkArchiverForProblems
import org.codehaus.plexus.archiver.ResourceIterator; //导入依赖的package包/类
/**
* Check for potential "Duplicate file" exception before archive processing starts
*
* @param archiver
*/
protected void checkArchiverForProblems( Archiver archiver )
{
for ( ResourceIterator iter = archiver.getResources(); iter.hasNext(); )
{
iter.next();
}
}
示例2: expandArchive
import org.codehaus.plexus.archiver.ResourceIterator; //导入依赖的package包/类
protected void expandArchive( Archiver archiver, File destDirectory )
throws IOException
{
for ( ResourceIterator iter = archiver.getResources(); iter.hasNext(); )
{
ArchiveEntry entry = iter.next();
String name = entry.getName();
name = name.replace( File.separatorChar, '/' );
File destFile = new File( destDirectory, name );
switch ( entry.getType() )
{
case ArchiveEntry.DIRECTORY:
if ( !destFile.exists() )
{
getLog().debug( "adding directory " + name + '/' );
if ( !destFile.mkdirs() )
{
throw new IOException( "Unable to create directory: " + destFile );
}
}
break;
case ArchiveEntry.FILE:
PlexusIoResource resource = entry.getResource();
boolean skip = false;
if ( !destFile.exists() )
{
getLog().debug( "adding file " + name );
}
else
{
long resLastModified = resource.getLastModified();
if ( resLastModified != PlexusIoResource.UNKNOWN_MODIFICATION_DATE )
{
long destFileLastModified = destFile.lastModified();
if ( resLastModified <= destFileLastModified )
{
skip = true;
}
else
{
getLog().debug( "updating file " + name );
}
}
}
if ( !skip )
{
InputStream contents = resource.getContents();
RawInputStreamFacade facade = new RawInputStreamFacade( contents );
FileUtils.copyStreamToFile( facade, destFile );
}
break;
default:
throw new ArchiverException( "Unknown archive entry type: " + entry.getType() );
}
}
}