Examples of WeakZipFile


Examples of org.apache.felix.framework.util.WeakZipFileFactory.WeakZipFile

        // Save and process the bundle JAR.
        initialize(byReference, is);

        // Open shared copy of the JAR file.
        WeakZipFile zipFile = null;
        try
        {
            // Open bundle JAR file.
            zipFile = m_zipFactory.create(m_bundleFile);
            // Error if no jar file.
            if (zipFile == null)
            {
                throw new IOException("No JAR file found.");
            }
            m_zipFile = zipFile;
        }
        catch (Exception ex)
        {
            if (zipFile != null) zipFile.close();
            throw ex;
        }
    }
View Full Code Here

Examples of org.apache.felix.framework.util.WeakZipFileFactory.WeakZipFile

        }

        try
        {
            WeakZipFileFactory factory = new WeakZipFileFactory(1);
            WeakZipFile zipFile = factory.create(tmpZip);
            assertTrue("Zip file not recorded.",
                factory.getZipZiles().contains(zipFile));
            assertTrue("Open zip file not recorded.",
                factory.getOpenZipZiles().contains(zipFile));
            ZipEntry ze = zipFile.getEntry(ENTRY_NAME);
            assertNotNull("Zip entry not found", ze);
            byte[] firstHalf = new byte[contentBytes.length / 2];
            byte[] secondHalf = new byte[contentBytes.length - firstHalf.length];
            InputStream is = zipFile.getInputStream(ze);
            is.read(firstHalf);
            zipFile.closeWeakly();
            assertTrue("Zip file not recorded.",
                factory.getZipZiles().contains(zipFile));
            assertFalse("Open zip file still recorded.",
                factory.getOpenZipZiles().contains(zipFile));
            is.read(secondHalf);
            assertTrue("Zip file not recorded.",
                factory.getZipZiles().contains(zipFile));
            assertTrue("Open zip file not recorded.",
                factory.getOpenZipZiles().contains(zipFile));
            byte[] complete = new byte[firstHalf.length + secondHalf.length];
            System.arraycopy(firstHalf, 0, complete, 0, firstHalf.length);
            System.arraycopy(secondHalf, 0, complete, firstHalf.length, secondHalf.length);
            String completeString = new String(complete);
            assertEquals(contentString, completeString);
            zipFile.close();
        }
        catch (IOException ex)
        {
            fail("Unable to read zip file entry: " + ex);
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.