JavaScript is disabled on your browser.
gnu.inet.http

Class ByteArrayResponseBodyReader

  • All Implemented Interfaces:
    ResponseBodyReader


    public class ByteArrayResponseBodyReader
    extends java.lang.Object
    implements ResponseBodyReader 
    Simple response body reader that stores content in a byte array.
    • Field Summary

      Fields
      Modifier and Type Field and Description
      protected byte[] content
      The content.
      protected int len
      The length of the buffer.
      protected int pos
      The position in the content at which the next write will occur.
    • Constructor Summary

      Constructors
      Constructor and Description
      ByteArrayResponseBodyReader ()
      Constructs a new byte array response body reader.
      ByteArrayResponseBodyReader (int size)
      Constructs a new byte array response body reader with the specified initial buffer size.
    • Method Summary

      Methods
      Modifier and Type Method and Description
      boolean accept (Request request, Response response)
      This reader accepts all responses.
      void close ()
      Notifies the reader that the end of the content was reached.
      void read (byte[] buffer, int offset, int length)
      Receive notification of body content.
      byte[] toByteArray ()
      Retrieves the content of this reader as a byte array.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • content

        protected byte[] content
        The content.
      • pos

        protected int pos
        The position in the content at which the next write will occur.
      • len

        protected int len
        The length of the buffer.
    • Constructor Detail

      • ByteArrayResponseBodyReader

        public ByteArrayResponseBodyReader()
        Constructs a new byte array response body reader.
      • ByteArrayResponseBodyReader

        public ByteArrayResponseBodyReader(int size)
        Constructs a new byte array response body reader with the specified initial buffer size.
        Parameters:
        size - the initial buffer size
    • Method Detail

      • read

        public void read(byte[] buffer,
         int offset,
         int length)
        Description copied from interface: ResponseBodyReader
        Receive notification of body content.
        Specified by:
        read in interface ResponseBodyReader
        Parameters:
        buffer - the content buffer
        offset - the offset within the buffer that content starts
        length - the length of the content
      • toByteArray

        public byte[] toByteArray()
        Retrieves the content of this reader as a byte array. The size of the returned array is the number of bytes read.

AltStyle によって変換されたページ (->オリジナル) /