Class MultipartBody

java.lang.Object
com.ning.http.client.multipart.MultipartBody
All Implemented Interfaces:
Body, RandomAccessBody, Closeable, AutoCloseable

public class MultipartBody extends Object implements RandomAccessBody
  • Constructor Details

    • MultipartBody

      public MultipartBody(List<Part> parts, String contentType, long contentLength, byte[] boundary)
  • Method Details

    • close

      public void close() throws IOException
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Throws:
      IOException
    • getContentLength

      public long getContentLength()
      Description copied from interface: Body
      Gets the length of the body.
      Specified by:
      getContentLength in interface Body
      Returns:
      The length of the body in bytes, or negative if unknown.
    • getContentType

      public String getContentType()
    • getBoundary

      public byte[] getBoundary()
    • transferTo

      public long transferTo(long position, WritableByteChannel target) throws IOException
      Description copied from interface: RandomAccessBody
      Transfers the specified chunk of bytes from this body to the specified channel.
      Specified by:
      transferTo in interface RandomAccessBody
      Parameters:
      position - The zero-based byte index from which to start the transfer, must not be negative.
      target - The destination channel to transfer the body chunk to, must not be null.
      Returns:
      The non-negative number of bytes actually transferred.
      Throws:
      IOException - If the body chunk could not be transferred.
    • read

      public long read(ByteBuffer buffer) throws IOException
      Description copied from interface: Body
      Reads the next chunk of bytes from the body.
      Specified by:
      read in interface Body
      Parameters:
      buffer - The buffer to store the chunk in, must not be null.
      Returns:
      The non-negative number of bytes actually read or -1 if the body has been read completely.
      Throws:
      IOException - If the chunk could not be read.