本文整理汇总了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().
}
}
示例2: ZipFileArchiveExtractor
import java.util.zip.ZipFile; //导入方法依赖的package包/类
public ZipFileArchiveExtractor(ZipFile zipFile)
{
super(zipFile.size());
this.zipFile = zipFile;
entries = zipFile.entries();
}
示例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());
}
}
示例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);
}