Package java.io

Examples of java.io.DataInputStream.readFully()


    byte[] fk = new byte[fullKeySize];
    byte[] header = new byte[headerSize];
    byte[] data = new byte[dataSize];
    dis.readFully(fk);
    dis.readFully(header);
    dis.readFully(data);
    in.close();
    try {
      T ret =
        callback.construct(data, header, routingKey, fk, canReadClientCache, canReadSlashdotCache, null, null);
      synchronized(this) {
View Full Code Here


  @Override
  public long decompress(InputStream is, OutputStream os, long maxLength, long maxCheckSizeBytes) throws IOException, CompressionOutputSizeException {
    byte[] props = new byte[5];
    DataInputStream dis = new DataInputStream(is);
    dis.readFully(props);
    CountedOutputStream cos = new CountedOutputStream(os);
   
    int dictionarySize = 0;
    for (int i = 0; i < 4; i++)
      dictionarySize += ((props[1 + i]) & 0xFF) << (i * 8);
 
View Full Code Here

            splitfileSingleCryptoAlgorithm = dis.readByte();
            if(!Metadata.isValidSplitfileCryptoAlgorithm(splitfileSingleCryptoAlgorithm))
                throw new StorageFormatException("Invalid splitfile crypto algorithm "+splitfileType);
            if(dis.readBoolean()) {
                splitfileSingleCryptoKey = new byte[32];
                dis.readFully(splitfileSingleCryptoKey);
            } else {
                splitfileSingleCryptoKey = null;
            }
            finalLength = dis.readLong();
            if(finalLength < 0)
View Full Code Here

        this.splitfileCryptoAlgorithm = dis.readByte();
        if(!Metadata.isValidSplitfileCryptoAlgorithm(splitfileCryptoAlgorithm))
            throw new StorageFormatException("Invalid splitfile crypto algorithm "+splitfileCryptoAlgorithm);
        if(dis.readBoolean()) {
            splitfileCryptoKey = new byte[32];
            dis.readFully(splitfileCryptoKey);
        } else {
            splitfileCryptoKey = null;
        }
        this.keyLength = dis.readInt(); // FIXME validate
        if(keyLength < SplitFileInserterSegmentStorage.getKeyLength(this))
View Full Code Here

        if(consecutiveRNFsCountAsSuccess < 0)
            throw new StorageFormatException("Bad consecutiveRNFsCountAsSuccess");
        specifySplitfileKeyInMetadata = dis.readBoolean();
        if(dis.readBoolean()) {
            hashThisLayerOnly = new byte[32];
            dis.readFully(hashThisLayerOnly);
        } else {
            hashThisLayerOnly = null;
        }
        topDontCompress = dis.readBoolean();
        topRequiredBlocks = dis.readInt();
View Full Code Here

            destination.write(buffer, 0, read);
            if (remaining > 0)
                remaining -= read;
        }
        byte[] checksum = new byte[checksumLength()];
        source.readFully(checksum);
        byte[] myChecksum = Fields.intToBytes((int)crc.getValue());
        if(!Arrays.equals(checksum, myChecksum))
            throw new ChecksumFailedException();
    }
View Full Code Here

        // Copy marker
        if(blockLength < 2)
          throwError("Invalid frame length", "The file includes an invalid frame (length "+blockLength+").");
        byte[] buf = new byte[blockLength - 2];
        dis.readFully(buf);
        dos.write(buf);
        Logger.minor(this, "Copied start-of-frame marker length "+(blockLength-2));

        if(baos != null)
          baos.writeTo(output); // will continue; at end
View Full Code Here

          dos.writeByte(thumbX);
          int thumbY = dis.readUnsignedByte();
          dos.writeByte(thumbY);
          int thumbLen = thumbX * thumbY * 3;
          byte[] buf = new byte[thumbLen];
          dis.readFully(buf);
          dos.write(buf);
        } else if(type.equals("JFXX")) {
          // JFIF extension marker
          int extensionCode = dis.readUnsignedByte();
          if(extensionCode == 0x10 || extensionCode == 0x11 || extensionCode == 0x13) {
View Full Code Here

        if(valid) {
          // Essential, non-terminal, but unparsed frames.
          if(blockLength < 2)
            throwError("Invalid frame length", "The file includes an invalid frame (length "+blockLength+").");
          byte[] buf = new byte[blockLength - 2];
          dis.readFully(buf);
          dos.write(buf);
          Logger.minor(this, "Essential frame type "+Integer.toHexString(markerType)+" length "+(blockLength-2)+" offset at end "+cis.count());
        } else {
          if(markerType >= 0xE0 && markerType <= 0xEF) {
            // APP marker. Can be safely deleted.
View Full Code Here

          // FIXME calculate the CRC. It applies to a large number of frames, dependant on the format.
        }
        //Write out the frame
        byte[] frame = null;
        frame = new byte[frameLength-4];
        in.readFully(frame);
        out.writeInt(frameHeader);
        // FIXME CRCs may or may not work. I have not been able to find an mp3 file with CRCs but without free bitrate.
        if(hasCRC)
          out.writeShort(crc);
        out.write(frame);
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.