當前位置: 首頁>>代碼示例>>Java>>正文


Java ResourceIterator類代碼示例

本文整理匯總了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();
    }
}
 
開發者ID:play1-maven-plugin,項目名稱:play1-maven-plugin,代碼行數:13,代碼來源:AbstractArchivingMojo.java

示例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() );
        }
    }
}
 
開發者ID:play1-maven-plugin,項目名稱:play1-maven-plugin,代碼行數:58,代碼來源:AbstractArchivingMojo.java


注:本文中的org.codehaus.plexus.archiver.ResourceIterator類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。