Package java.util.zip

Examples of java.util.zip.ZipException


                        super.close();
                        inf.end();
                    }
                };
            default:
                throw new ZipException( "Found unsupported compression method " + ze.getMethod() );
        }
    }
View Full Code Here


            archive.seek( --off );
            curr = archive.read();
        }
        if ( !found )
        {
            throw new ZipException( "archive is not a ZIP archive" );
        }
        archive.seek( off + CFD_LOCATOR_OFFSET );
        byte[] cfdOffset = new byte[4];
        archive.readFully( cfdOffset );
        archive.seek( ( new ZipLong( cfdOffset ) ).getValue() );
View Full Code Here

            {
                return new String( bytes, encoding );
            }
            catch ( UnsupportedEncodingException uee )
            {
                throw new ZipException( uee.getMessage() );
            }
        }
    }
View Full Code Here

        {
            ZipShort headerId = new ZipShort( data, start );
            int length = ( new ZipShort( data, start + 2 ) ).getValue();
            if ( start + 4 + length > data.length )
            {
                throw new ZipException( "data starting at " + start + " is in unknown format" );
            }
            try
            {
                ZipExtraField ze = createExtraField( headerId );
                ze.parseFromLocalFileData( data, start + 4, length );
                v.addElement( ze );
            }
            catch ( InstantiationException ie )
            {
                throw new ZipException( ie.getMessage() );
            }
            catch ( IllegalAccessException iae )
            {
                throw new ZipException( iae.getMessage() );
            }
            start += ( length + 4 );
        }
        if ( start != data.length )
        { // array not exhausted
            throw new ZipException( "data starting at " + start + " is in unknown format" );
        }

        ZipExtraField[] result = new ZipExtraField[v.size()];
        v.copyInto( result );
        return result;
View Full Code Here

        }
        else if ( raf == null )
        {
            if ( entry.getCrc() != realCrc )
            {
                throw new ZipException( "bad CRC checksum for entry " + entry.getName() + ": "
                    + Long.toHexString( entry.getCrc() ) + " instead of " + Long.toHexString( realCrc ) );
            }

            if ( entry.getSize() != written - dataStart )
            {
                throw new ZipException( "bad size for entry " + entry.getName() + ": " + entry.getSize()
                    + " instead of " + ( written - dataStart ) );
            }
        }
        else
        { /* method is STORED and we used RandomAccessFile */
 
View Full Code Here

        // Size/CRC not required if RandomAccessFile is used
        if ( entry.getMethod() == STORED && raf == null )
        {
            if ( entry.getSize() == -1 )
            {
                throw new ZipException( "uncompressed size is required for STORED method when not writing to a"
                    + " file" );
            }
            if ( entry.getCrc() == -1 )
            {
                throw new ZipException( "crc checksum is required for STORED method when not writing to a file" );
            }
            entry.setComprSize( entry.getSize() );
        }

        if ( entry.getMethod() == DEFLATED && hasCompressionLevelChanged )
View Full Code Here

            {
                return name.getBytes( encoding );
            }
            catch ( UnsupportedEncodingException uee )
            {
                throw new ZipException( uee.getMessage() );
            }
        }
    }
View Full Code Here

        int start = 0;
        while (start <= data.length - WORD) {
            ZipShort headerId = new ZipShort(data, start);
            int length = (new ZipShort(data, start + 2)).getValue();
            if (start + WORD + length > data.length) {
                throw new ZipException("data starting at " + start
                    + " is in unknown format");
            }
            try {
                ZipExtraField ze = createExtraField(headerId);
                ze.parseFromLocalFileData(data, start + WORD, length);
                v.addElement(ze);
            } catch (InstantiationException ie) {
                throw new ZipException(ie.getMessage());
            } catch (IllegalAccessException iae) {
                throw new ZipException(iae.getMessage());
            }
            start += (length + WORD);
        }
        if (start != data.length) { // array not exhausted
            throw new ZipException("data starting at " + start
                + " is in unknown format");
        }

        ZipExtraField[] result = new ZipExtraField[v.size()];
        v.copyInto(result);
View Full Code Here

            def.reset();

            written += entry.getCompressedSize();
        } else if (raf == null) {
            if (entry.getCrc() != realCrc) {
                throw new ZipException("bad CRC checksum for entry "
                                       + entry.getName() + ": "
                                       + Long.toHexString(entry.getCrc())
                                       + " instead of "
                                       + Long.toHexString(realCrc));
            }

            if (entry.getSize() != written - dataStart) {
                throw new ZipException("bad size for entry "
                                       + entry.getName() + ": "
                                       + entry.getSize()
                                       + " instead of "
                                       + (written - dataStart));
            }
View Full Code Here

        }

        // Size/CRC not required if RandomAccessFile is used
        if (entry.getMethod() == STORED && raf == null) {
            if (entry.getSize() == -1) {
                throw new ZipException("uncompressed size is required for"
                                       + " STORED method when not writing to a"
                                       + " file");
            }
            if (entry.getCrc() == -1) {
                throw new ZipException("crc checksum is required for STORED"
                                       + " method when not writing to a file");
            }
            entry.setCompressedSize(entry.getSize());
        }
View Full Code Here

TOP

Related Classes of java.util.zip.ZipException

Copyright © 2018 www.massapicom. 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.