当前位置: 首页>>代码示例>>Java>>正文


Java ZipFile.size方法代码示例

本文整理汇总了Java中java.util.zip.ZipFile.size方法的典型用法代码示例。如果您正苦于以下问题:Java ZipFile.size方法的具体用法?Java ZipFile.size怎么用?Java ZipFile.size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.util.zip.ZipFile的用法示例。


在下文中一共展示了ZipFile.size方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testCloseQuietlyZipFileOpen

import java.util.zip.ZipFile; //导入方法依赖的package包/类
@Test
public void testCloseQuietlyZipFileOpen() throws IOException {
  final ZipFile zf = new ZipFile("test/VASSAL/tools/io/test.zip");
  IOUtils.closeQuietly(zf);

  try {
    zf.size();
    fail();
  }
  catch (IllegalStateException e) {
    // This is the expected behavior of size().
  }
}
 
开发者ID:ajmath,项目名称:VASSAL-src,代码行数:14,代码来源:IOUtilsTest.java

示例2: ZipFileArchiveExtractor

import java.util.zip.ZipFile; //导入方法依赖的package包/类
public ZipFileArchiveExtractor(ZipFile zipFile)
{
	super(zipFile.size());
	this.zipFile = zipFile;
	entries = zipFile.entries();
}
 
开发者ID:equella,项目名称:Equella,代码行数:7,代码来源:FileSystemServiceImpl.java

示例3: unpack

import java.util.zip.ZipFile; //导入方法依赖的package包/类
static void unpack(final ZipFile zipFile, final File destFolder) throws IOException
{
	zipFile.size();
	for( Enumeration<? extends ZipEntry> en = zipFile.entries(); en.hasMoreElements(); )
	{
		ZipEntry entry = en.nextElement();
		String name = entry.getName();
		File entryFile = new File(destFolder.getCanonicalPath() + "/" + name);
		if( name.endsWith("/") )
		{
			if( !entryFile.exists() && !entryFile.mkdirs() )
			{
				throw new IOException(FOLDER_ERROR + entryFile);
			}
		}
		else
		{
			File folder = entryFile.getParentFile();
			if( !folder.exists() && !folder.mkdirs() )
			{
				throw new IOException(FOLDER_ERROR + folder);
			}
			OutputStream out = new BufferedOutputStream(new FileOutputStream(entryFile, false));
			try
			{
				InputStream in = zipFile.getInputStream(entry);
				try
				{
					IoUtil.copyStream(in, out, 1024);
				}
				finally
				{
					in.close();
				}
			}
			finally
			{
				out.close();
			}
		}
		entryFile.setLastModified(entry.getTime());
	}
}
 
开发者ID:equella,项目名称:Equella,代码行数:44,代码来源:TleShadingPathResolver.java

示例4: processUpload

import java.util.zip.ZipFile; //导入方法依赖的package包/类
protected ImportResult processUpload(ZipFile zipFile, String filename) throws IOException
{
    if (zipFile.size() > 2)
    {
        throw new WebScriptException(Status.STATUS_BAD_REQUEST, "cmm.rest_api.model.import_invalid_zip_package");
    }

    CustomModel customModel = null;
    String shareExtModule = null;
    Enumeration<? extends ZipEntry> entries = zipFile.entries();
    while (entries.hasMoreElements())
    {
        ZipEntry entry = entries.nextElement();

        if (!entry.isDirectory())
        {
            final String entryName = entry.getName();
            try (InputStream input = new BufferedInputStream(zipFile.getInputStream(entry), BUFFER_SIZE))
            {
                if (!(entryName.endsWith(CustomModelServiceImpl.SHARE_EXT_MODULE_SUFFIX)) && customModel == null)
                {
                    try
                    {
                        M2Model m2Model = M2Model.createModel(input);
                        customModel = importModel(m2Model);
                    }
                    catch (DictionaryException ex)
                    {
                        if (shareExtModule == null)
                        {
                            // Get the input stream again, as the zip file doesn't support reset.
                            try (InputStream moduleInputStream = new BufferedInputStream(zipFile.getInputStream(entry), BUFFER_SIZE))
                            {
                                shareExtModule = getExtensionModule(moduleInputStream, entryName);
                            }

                            if (shareExtModule == null)
                            {
                                throw new WebScriptException(Status.STATUS_BAD_REQUEST, "cmm.rest_api.model.import_invalid_zip_entry_format", new Object[] { entryName });
                            }
                        }
                        else
                        {
                            throw new WebScriptException(Status.STATUS_BAD_REQUEST, "cmm.rest_api.model.import_invalid_model_entry", new Object[] { entryName });
                        }
                    }
                }
                else
                {
                    shareExtModule = getExtensionModule(input, entryName);
                    if (shareExtModule == null)
                    {
                        throw new WebScriptException(Status.STATUS_BAD_REQUEST, "cmm.rest_api.model.import_invalid_ext_module_entry", new Object[] { entryName });
                    }
                }
            }
        }
    }

    return new ImportResult(customModel, shareExtModule);
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:62,代码来源:CustomModelUploadPost.java


注:本文中的java.util.zip.ZipFile.size方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。