Package java.io

Examples of java.io.DataInputStream.readFully()


    byte[] data = new byte[(int)size];
    InputStream is = bucket.getInputStreamUnbuffered();
    DataInputStream dis = null;
    try {
      dis = new DataInputStream(is);
      dis.readFully(data);
    } finally {
      Closer.close(dis);
      Closer.close(is);
    }
    return data;
View Full Code Here


      byte[] buf = new byte[splitSize];
      for(int i=0;i<bucketCount;i++) {
        int len = (int) Math.min(splitSize, remainingLength);
        Bucket bucket = bf.makeBucket(len);
        buckets[i] = bucket;
        dis.readFully(buf, 0, len);
        remainingLength -= len;
        OutputStream os = bucket.getOutputStreamUnbuffered();
        try {
          os.write(buf, 0, len);
        } finally {
View Full Code Here

  public void readFilter(InputStream input, OutputStream output, String charset, HashMap<String, String> otherParams,
          FilterCallback cb) throws DataFilterException, IOException {
    DataInputStream dis = new DataInputStream(input);
    // Check the header
    byte[] headerCheck = new byte[HEADER_SIZE];
    dis.readFully(headerCheck);
    if((!Arrays.equals(headerCheck, gif87aHeader)) && (!Arrays.equals(headerCheck, gif89aHeader))) {
      throwHeaderError(l10n("invalidHeaderTitle"), l10n("invalidHeader"));
    }
    output.write(headerCheck);
    FileUtil.copy(dis, output, -1);
View Full Code Here

    try {
                        long offset = 0;
      dis = new DataInputStream(input);
      // Check the header
      byte[] headerCheck = new byte[pngHeader.length];
      dis.readFully(headerCheck);
                        offset+=pngHeader.length;
      if (!Arrays.equals(headerCheck, pngHeader)) {
        // Throw an exception
        String message = l10n("invalidHeader");
        String title = l10n("invalidHeaderTitle");
View Full Code Here

        baos.reset();
        String chunkTypeString = null;
        // Length of the chunk
        byte[] lengthBytes = new byte[4];
        try {
          dis.readFully(lengthBytes);
          offset+=4;
        } catch (EOFException e) {
          // FIXME optimise out the throw, don't use readFully?
          // This will happen once per filtering.
          // We can't use available() for reasons explained in
View Full Code Here

          Logger.minor(this, "length " + length+ "(offset=0x"+Long.toHexString(offset)+") ");
        if (dos != null)
          dos.write(lengthBytes);

        // Type of the chunk : Should match [a-zA-Z]{4}
        dis.readFully(lengthBytes);
                                offset+=4;
        StringBuilder sb = new StringBuilder();
        byte[] chunkTypeBytes = new byte[4];
        for (int i = 0; i < 4; i++) {
          char val = (char) lengthBytes[i];
View Full Code Here

          dos.write(chunkTypeBytes);

        // Content of the chunk
        byte[] chunkData = new byte[length];
        if(length > 0) {
          dis.readFully(chunkData, 0, length);
          offset+=length;
          if (logMINOR)
            if (logDEBUG)
              Logger.minor(this, "data (offset=0x"+Long.toHexString(offset)+") "+ (chunkData.length == 0 ? "null" : HexUtil.bytesToHex(chunkData)));
            else
View Full Code Here

            dos.write(chunkData);
        }

        // CRC of the chunk
        byte[] crcLengthBytes = new byte[4];
        dis.readFully(crcLengthBytes);
        offset+=4;
        if(logMINOR) Logger.minor(this, "CRC offset=0x"+Long.toHexString(offset));
        if (dos != null)
          dos.write(crcLengthBytes);
View Full Code Here

    InputStream in = block.data.getInputStream();
    DataInputStream dis = new DataInputStream(in);
    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 =
View Full Code Here

    DataInputStream dis = new DataInputStream(in);
    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);
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.