當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。