本文整理了Java中java.util.zip.ZipFile.size()
方法的一些代码示例,展示了ZipFile.size()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZipFile.size()
方法的具体详情如下:
包路径:java.util.zip.ZipFile
类名称:ZipFile
方法名:size
[英]Returns the number of ZipEntries in this ZipFile.
[中]返回此ZipFile中的ZipPentries数。
代码示例来源:origin: zeroturnaround/zt-zip
if (zf1.size() != zf2.size()) {
log.debug("Number of entries changed (" + zf1.size() + " vs " + zf2.size() + ").");
return false;
代码示例来源:origin: neo4j/neo4j
@Test
public void pruneAndArchiveLastLog() throws IOException
{
life.start();
generateTransactionLogFiles( logFiles );
long highestLogVersion = logFiles.getHighestLogVersion();
File highestLogFile = logFiles.getHighestLogFile();
long fileSizeBeforePrune = highestLogFile.length();
int bytesToPrune = 5;
long byteOffset = fileSizeBeforePrune - bytesToPrune;
LogPosition prunePosition = new LogPosition( highestLogVersion, byteOffset );
logPruner.truncate( prunePosition );
assertEquals( TOTAL_NUMBER_OF_LOG_FILES, logFiles.logFiles().length );
assertEquals( byteOffset, highestLogFile.length() );
File corruptedLogsDirectory = new File( databaseDirectory, CorruptedLogsTruncator.CORRUPTED_TX_LOGS_BASE_NAME );
assertTrue( corruptedLogsDirectory.exists() );
File[] files = corruptedLogsDirectory.listFiles();
assertEquals( 1, files.length );
File corruptedLogsArchive = files[0];
checkArchiveName( highestLogVersion, byteOffset, corruptedLogsArchive );
try ( ZipFile zipFile = new ZipFile( corruptedLogsArchive ) )
{
assertEquals( 1, zipFile.size() );
checkEntryNameAndSize( zipFile, highestLogFile.getName(), bytesToPrune );
}
}
代码示例来源:origin: neo4j/neo4j
try ( ZipFile zipFile = new ZipFile( corruptedLogsArchive ) )
assertEquals( 7, zipFile.size() );
checkEntryNameAndSize( zipFile, highestCorrectLogFile.getName(), bytesToPrune );
long nextLogFileIndex = highestCorrectLogFileIndex + 1;
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.aspectj
private boolean isReallyOpen() {
try {
zipFile.size(); // this will fail if the file has been closed
// for
// some reason;
return true;
} catch (IllegalStateException ex) {
// this means the zip file is closed...
return false;
}
}
代码示例来源:origin: pl.edu.icm.yadda/yadda-analysis-impl
@Override
public int getEstimatedSize() throws UnsupportedOperationException {
return zipFile.size();
}
代码示例来源:origin: stackoverflow.com
int zipEntriesCount(String path) throws IOException {
ZipFile zf= new ZipFile(path);
return zf.size();
}
代码示例来源:origin: jboss-fuse/fabric8
public static boolean isZipValid(String fileName) {
boolean result = true;
try {
ZipFile zipFile = new ZipFile(fileName);
zipFile.size();
} catch (Exception e){
result = false;
LOGGER.error("Patch zip [{}] is not valid. ", fileName, e);
}
return result;
}
代码示例来源:origin: uk.ac.gate.mimir/mimir-core
public static long totalDocumentsInZipCollection(File indexDirectory)
throws IOException {
long totalDocs = 0;
File[] zipCollectionFiles =
indexDirectory
.listFiles(DocumentCollection.CollectionFile.FILENAME_FILTER);
for(File zip : zipCollectionFiles) {
try(ZipFile zf = new ZipFile(zip)) {
totalDocs += zf.size();
}
}
return totalDocs;
}
代码示例来源:origin: anno4j/anno4j
private static boolean isJarEmpty(File jar) throws ZipException, IOException {
if (jar == null || !jar.canRead())
return true;
ZipFile zip = new ZipFile(jar);
try {
return zip.size() <= 0;
} finally {
zip.close();
}
}
代码示例来源:origin: stackoverflow.com
JarFile f = new JarFile(new File("path.jar"));
System.out.println(f.size());
代码示例来源:origin: stackoverflow.com
try {
ZipFile zipfile = new ZipFile(archive);
int entries = zipfile.size();
int total = 0;
if(onZipListener != null)
onZipListener.onUncompressStart(archive);
for (Enumeration<?> e = zipfile.entries(); e.hasMoreElements();) {
ZipEntry entry = (ZipEntry) e.nextElement();
if(onZipListener != null)
onZipListener.onUncompressProgress(archive, (int) (total++ * 100 / entries));
unzipEntry(zipfile, entry, path);
}
zipfile.close();
} catch (Exception e) {
e.printStackTrace();
}
代码示例来源:origin: com.atlassian.org.eclipse.sisu/org.eclipse.sisu.inject
/**
* Returns a string array listing the entries in the given zip file.
*
* @param zipFile The zip file
* @return Array of entry names
*/
private static String[] getEntryNames( final ZipFile zipFile )
throws IOException
{
try
{
final String names[] = new String[zipFile.size()];
final Enumeration<? extends ZipEntry> e = zipFile.entries();
for ( int i = 0; i < names.length; i++ )
{
names[i] = e.nextElement().getName();
}
return names;
}
finally
{
zipFile.close();
}
}
代码示例来源:origin: bcdev/beam
private static InputStream createZIPInputStream(File file) throws IOException {
final ZipFile productZip = new ZipFile(file, ZipFile.OPEN_READ);
if (productZip.size() != 1) {
throw new IllegalFileFormatException("Illegal ZIP format, single file entry expected.");
}
final Enumeration<? extends ZipEntry> entries = productZip.entries();
final ZipEntry zipEntry = entries.nextElement();
if (zipEntry == null || zipEntry.isDirectory()) {
throw new IllegalFileFormatException("Illegal ZIP format, single file entry expected.");
}
return productZip.getInputStream(zipEntry);
}
代码示例来源:origin: org.apache.servicemix/servicemix-core
private boolean isAvailable(File file) {
// First check to see if the file is still growing
if (!FileUtil.isFileFullyAvailable(file)) {
LOGGER.warn("File is still being copied, deployment deferred to next cycle: {}", file.getName());
return false;
}
// If file size is consistent, do a foolproof check of the zip file
try {
ZipFile zip = new ZipFile(file);
zip.size();
zip.close();
} catch (IOException e) {
LOGGER.warn("Unable to open deployment file, deployment deferred to next cycle: {}", file.getName());
return false;
}
return true;
}
代码示例来源:origin: org.onehippo.cms7/hippo-repository-testutils
public static void assertEntries(ZipFile zip, String... names) {
final int size = zip.size();
assertEquals(names.length, size);
final Enumeration<? extends ZipEntry> entries = zip.entries();
for (int i = 0; i < size; i++) {
assertTrue(entries.hasMoreElements());
assertEquals(names[i], entries.nextElement().getName());
}
assertFalse(entries.hasMoreElements());
}
代码示例来源:origin: org.apache.beam/beam-sdks-java-core
private void assertZipOnlyContains(String zipFileEntry) throws IOException {
try (ZipFile zippedFile = new ZipFile(zipFile)) {
assertEquals(1, zippedFile.size());
ZipEntry entry = zippedFile.entries().nextElement();
assertEquals(zipFileEntry, entry.getName());
}
}
代码示例来源:origin: fcrepo3/fcrepo
@Test
public void testZip() throws Exception {
Zip.zip(ZIP_FILE, SRC_DIR.listFiles());
ZipFile zf = new ZipFile(ZIP_FILE);
try {
assertEquals(5, zf.size());
} finally {
zf.close();
}
}
代码示例来源:origin: marklogic/marklogic-data-hub
@Test
public void exportMultipleJobs() throws IOException, InterruptedException {
File zipFile = exportPath.toFile();
assertFalse(zipFile.exists());
String[] jobs = { jobIds.get(0), jobIds.get(1) };
jobManager.exportJobs(exportPath, jobs);
assertTrue(zipFile.exists());
ZipFile actual = new ZipFile(zipFile);
// There should be two job and four trace documents
int actualSize = actual.size();
actual.close();
assertEquals(6, actualSize);
}
代码示例来源:origin: marklogic/marklogic-data-hub
@Test
public void exportAllJobs() throws IOException {
File zipFile = exportPath.toFile();
assertFalse(zipFile.exists());
jobManager.exportJobs(exportPath, null);
assertTrue(zipFile.exists());
ZipFile actual = new ZipFile(zipFile);
assertEquals(12, actual.size());
actual.close();
}
代码示例来源:origin: marklogic/marklogic-data-hub
@Test
public void exportOneJob() throws IOException {
File zipFile = exportPath.toFile();
assertFalse(zipFile.exists());
String[] jobs = { jobIds.get(0) };
jobManager.exportJobs(exportPath, jobs);
assertTrue(zipFile.exists());
ZipFile actual = new ZipFile(zipFile);
// There should be one job and two trace documents
int actualSize = actual.size();
actual.close();
assertEquals(3, actualSize);
}
内容来源于网络,如有侵权,请联系作者删除!