Package org.apache.commons.io.input

Examples of org.apache.commons.io.input.BoundedInputStream


            long length = randomAccessFile.length() - header.getMp3StartByte();
            if (new String(tag).equals("TAG")) {
                length -= 128;
            }
            randomAccessFile.seek(header.getMp3StartByte());
            InputStream is = new BoundedInputStream(new RandomAccessFileInputstream(randomAccessFile), length);
            MessageDigest m = MessageDigest.getInstance("MD5");
            byte[] buffer = new byte[8192];
            int read;
            while ((read = is.read(buffer)) > 0) {
                m.update(buffer, 0, read);
            }
            randomAccessFile.close();
            return new BigInteger(1, m.digest()).toString(16) + String.format("-%08x", length);
        } catch (TagException e) {
View Full Code Here


      final long streamlength = Long.parseLong(cl);
      fileLength = startPos + streamlength;

      // Java has a bug with >2GB request streams.  It won't bounds check
      // the reads so the transfer blocks until the server times out
      in = new BoundedInputStream(in, streamlength);
    }

    return in;
  }
View Full Code Here

        writer.write(fileType);
        writer.write("\nLogLength:");
        writer.write(fileLengthStr);
        writer.write("\nLog Contents:\n");
        // ByteLevel
        BoundedInputStream bis =
            new BoundedInputStream(valueStream, fileLength);
        InputStreamReader reader = new InputStreamReader(bis);
        int currentRead = 0;
        int totalRead = 0;
        while ((currentRead = reader.read(cbuf, 0, bufferSize)) != -1) {
          writer.write(cbuf);
View Full Code Here

        parseMessage();
        long limit = getBodyStartOctet() -2;
        if (limit < 0) {
            limit = 0;
        }
        return new BoundedInputStream(getFullContent(), limit);

    }
View Full Code Here

     */
    public InputStream getInputStream() throws IOException {
        // wrap the streams in a BoundedInputStream to make sure it really match with the stored size.
        switch (type) {
        case Full:
            return new BoundedInputStream(ResultUtils.toInput(m), size());
        default:
            return new BoundedInputStream(m.getBodyContent(), size());
        }
      
    }
View Full Code Here

    public InputStream getHeaderContent() throws IOException {
        long limit = getBodyStartOctet() -2;
        if (limit < 0) {
            limit = 0;
        }
        return new BoundedInputStream(getFullContent(), limit);
    }
View Full Code Here

        writer.write(fileType);
        writer.write("\nLogLength:");
        writer.write(fileLengthStr);
        writer.write("\nLog Contents:\n");
        // ByteLevel
        BoundedInputStream bis =
            new BoundedInputStream(valueStream, fileLength);
        InputStreamReader reader = new InputStreamReader(bis);
        int currentRead = 0;
        int totalRead = 0;
        while ((currentRead = reader.read(cbuf, 0, bufferSize)) != -1) {
          writer.write(cbuf, 0, currentRead);
View Full Code Here

        writer.write(fileType);
        writer.write("\nLogLength:");
        writer.write(fileLengthStr);
        writer.write("\nLog Contents:\n");
        // ByteLevel
        BoundedInputStream bis =
            new BoundedInputStream(valueStream, fileLength);
        InputStreamReader reader = new InputStreamReader(bis);
        int currentRead = 0;
        int totalRead = 0;
        while ((currentRead = reader.read(cbuf, 0, bufferSize)) != -1) {
          writer.write(cbuf, 0, currentRead);
View Full Code Here

      try {
        String logType = valueStream.readUTF();
        String logLengthStr = valueStream.readUTF();
        currentLogLength = Long.parseLong(logLengthStr);
        currentLogData =
            new BoundedInputStream(valueStream, currentLogLength);
        currentLogData.setPropagateClose(false);
        currentLogISR = new InputStreamReader(currentLogData);
        currentLogType = logType;
      } catch (EOFException e) {
      }
View Full Code Here

  @Override
  public InputStream getInputStream() throws IOException {
    FSDataInputStream inputStream = localFS.open(inputFile);
    inputStream.seek(startOffset);
    return new BoundedInputStream(inputStream, compressedSize);
  }
View Full Code Here

TOP

Related Classes of org.apache.commons.io.input.BoundedInputStream

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.