Package java.util.zip

Examples of java.util.zip.DataFormatException


        decompresser.setInput(in, inPos, inLen);
        decompresser.finished();
        try {
            int len = decompresser.inflate(out, outPos, outLen);
            if (len != outLen) {
                throw new DataFormatException(len + " " + outLen);
            }
        } catch (DataFormatException e) {
            throw DbException.get(ErrorCode.COMPRESSION_ERROR, e);
        }
        decompresser.end();
View Full Code Here


        buf.order(ByteOrder.LITTLE_ENDIAN);
        int oldPos = buf.position();
        GZipHeader hdr = new GZipHeader();

        if (MAGIC_1 != buf.get()) {
            throw new DataFormatException("Incorrect GZip magic number");
        }
        if (MAGIC_2 != buf.get()) {
            throw new DataFormatException("Incorrect GZip magic number");
        }
        buf.get();
        int flags = buf.get();
        hdr.setTimestamp(readUInt32LE(buf) * 1000L);
        buf.get();
View Full Code Here

    public static Trailer readGZipTrailer(ByteBuffer buf)
        throws DataFormatException
    {
        if (buf.remaining() < TRAILER_SIZE) {
            throw new DataFormatException("No GZIP trailer");
        }
        Trailer t = new Trailer();
        t.setChecksum(readUInt32LE(buf));
        t.setLength(readUInt32LE(buf));
        return t;
View Full Code Here

                        byte[] trailer = trailerBuf.toByteArray();
                        assert(trailer.length == GZipHeader.TRAILER_SIZE);
                        ByteBuffer tb = ByteBuffer.wrap(trailer, 0, GZipHeader.TRAILER_SIZE);
                        GZipHeader.Trailer t = GZipHeader.readGZipTrailer(tb);
                        if (t.getLength() != inflater.getBytesWritten()) {
                            throw new DataFormatException("Bad length: expected " + t.getLength() +
                                                          " and actually read " + inflater.getBytesWritten());
                        }
                        if (t.getChecksum() != checksum.getValue()) {
                            throw new DataFormatException("Bad crc: expected " + t.getChecksum() +
                                                          " and actually got " + checksum.getValue());
                        }

                        trailerDone = true;
                    }
View Full Code Here

               int m = input.read(inputBuffer);
              
               if (m == -1)
               {
                  //it shouldn't be here, throw exception
                  throw new DataFormatException("Input is over while inflater still expecting data");
               }
               else
               {
                  //feed the data in
                  inflater.setInput(inputBuffer);
                  n = inflater.inflate(buf, offset, len);
                  if (n > 0)
                  {
                     read += n;
                     offset += n;
                     len -= n;
                  }
               }
            }
            else
            {
               //it shouldn't be here, throw
               throw new DataFormatException("Inflater is neither finished nor needing input.");
            }
         }
         else
         {
            read += n;
View Full Code Here

   *             If data was not supported.
   */
  public int compareValues(LiteralRestriction restriction)
      throws DataFormatException {
    if (restriction.getValueType() != valueType) {
      throw new DataFormatException(
          "Value types did not match. Value type "
              + restriction.getValueType() + " was compared to "
              + valueType);
    }

    if (valueType == Field.FieldType.DATE) {
      return dateValue.compareTo(restriction.getDateValue());
    } else if (valueType == Field.FieldType.DOUBLE) {
      if (doubleValue > restriction.getDoubleValue()) {
        return 1;
      } else if (doubleValue < restriction.getDoubleValue()) {
        return -1;
      } else {
        return 0;
      }
    } else if (valueType == Field.FieldType.INT) {
      if (intValue > restriction.getIntValue()) {
        return 1;
      } else if (intValue < restriction.getIntValue()) {
        return -1;
      } else {
        return 0;
      }
    } else if (valueType == Field.FieldType.STRING) {
      return stringValue.compareTo(restriction.getValueAsString());
    } else if (valueType == Field.FieldType.UNKNOWN) {
      return 0;
    }

    throw new DataFormatException("Value types did not match. Value type "
        + restriction.getValueType() + " was compared to " + valueType);
  }
View Full Code Here

               int m = input.read(inputBuffer);

               if (m == -1)
               {
                  //it shouldn't be here, throw exception
                  throw new DataFormatException("Input is over while inflater still expecting data");
               }
               else
               {
                  //feed the data in
                  inflater.setInput(inputBuffer, 0, m);
                  n = inflater.inflate(buf, offset, len);
                  if (n > 0)
                  {
                     read += n;
                     offset += n;
                     len -= n;
                  }
               }
            }
            else
            {
               //it shouldn't be here, throw
               throw new DataFormatException("Inflater is neither finished nor needing input.");
            }
         }
         else
         {
            read += n;
View Full Code Here

        decompresser.setInput(in, inPos, inLen);
        decompresser.finished();
        try {
            int len = decompresser.inflate(out, outPos, outLen);
            if (len != outLen) {
                throw new DataFormatException(len + " " + outLen);
            }
        } catch (DataFormatException e) {
            throw DbException.get(ErrorCode.COMPRESSION_ERROR, e);
        }
        decompresser.end();
View Full Code Here

          pin(pack, position);
          position += window.setInput(position, inf);
        } else if (inf.finished())
          return dstoff;
        else
          throw new DataFormatException();
      }
      dstoff += n;
    } while (dstoff < dstbuf.length);
    return dstoff;
  }
View Full Code Here

        position += block.remaining(position);
        pin(pack, position);
      } else if (inf.finished())
        return dstoff;
      else
        throw new DataFormatException();
    }
  }
View Full Code Here

TOP

Related Classes of java.util.zip.DataFormatException

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.