com.marklogic.http

## Class PartInputStream

- java.lang.Object
- - java.io.InputStream
  - - com.marklogic.http.PartInputStream

- All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable

      public class PartInputStream
      extends java.io.InputStream

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `PartInputStream(MultipartSplitter splitter)` Create a new `PartInputStream` backed by a given (shared) `MultipartSplitter`.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `int` | `available()`
    `void` | `close()` Closes this input stream and releases any system resources associated with the stream.
    `void` | `mark(int readlimit)` Marks the current position in this input stream.
    `boolean` | `markSupported()` Tests if this input stream supports the mark and reset methods.
    `int` | `read()` Reads the next byte of data from the input stream.
    `int` | `read(byte[] buf)` Reads some number of bytes from the input stream and stores them into the buffer array b.
    `int` | `read(byte[] buf, int offset, int len)` Reads up to `len` bytes of data from the input stream into an array of bytes.
    `void` | `reset()` Repositions this stream to the position at the time the mark method was last called on this input stream.
    `long` | `skip(long n)` Skips over and discards n bytes of data from this input stream.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### PartInputStream

          public PartInputStream(MultipartSplitter splitter)

      Create a new `PartInputStream` backed by a given (shared) `MultipartSplitter`. This input stream will return bytes until the underlying `MultipartSplitter` detects an end-of-part boundary, in which case the `PartInputStream` returns a length of -1 as an EOF indicator.

  - ### Method Detail

    - #### available

          public int available()

      Overrides:
        `available` in class `java.io.InputStream`

    - #### close

          public void close()

      Closes this input stream and releases any system resources associated with the stream.
      Specified by:
        `close` in interface `java.io.Closeable`
      Specified by:
        `close` in interface `java.lang.AutoCloseable`
      Overrides:
        `close` in class `java.io.InputStream`

    - #### mark

          public void mark(int readlimit)

      Marks the current position in this input stream.
      Overrides:
        `mark` in class `java.io.InputStream`

    - #### markSupported

          public boolean markSupported()

      Tests if this input stream supports the mark and reset methods.
      Overrides:
        `markSupported` in class `java.io.InputStream`

    - #### read

          public int read()
                   throws java.io.IOException

      Reads the next byte of data from the input stream.
      Specified by:
        `read` in class `java.io.InputStream`
      Throws:
        `java.io.IOException`

    - #### read

          public int read(byte[] buf)
                   throws java.io.IOException

      Reads some number of bytes from the input stream and stores them into the buffer array b.
      Overrides:
        `read` in class `java.io.InputStream`
      Throws:
        `java.io.IOException`

    - #### read

          public int read(byte[] buf,
                          int offset,
                          int len)
                   throws java.io.IOException

      Reads up to `len` bytes of data from the input stream into an array of bytes. An attempt is made to read as many as `len` bytes, but a smaller number may be read, possibly zero. The number of bytes actually read is returned as an integer.

      This method blocks until input data is available, end of file is detected, or an exception is thrown.

      If `buf` is `null`, a `NullPointerException` is thrown.

      If `offset` is negative, or `len` is negative, or `offset+len` is greater than the length of the array `buf`, then an `IndexOutOfBoundsException` is thrown.

      If `len` is zero, then no bytes are read and `0` is returned; otherwise, there is an attempt to read at least one byte. If no byte is available because the stream is at end of file, the value `-1` is returned; otherwise, at least one byte is read and stored into `buf`.

      In every case, elements `buf[0]` through `buf[offset]` and elements `buf[offset+len]` through `buf[buf.length-1]` are unaffected.

      If the first byte cannot be read for any reason other than end of file, then an `IOException` is thrown. In particular, an `IOException` is thrown if the input stream has been closed.

      Overrides:
        `read` in class `java.io.InputStream`
      Parameters:
        `buf` - - the buffer into which the data is read.
        `offset` - - the start offset in array `b` at which the data is written.
        `len` - - the maximum number of bytes to read.
      Returns:
        the total number of bytes read into the buffer, or `-1` if there is no more data because the end of the stream has been reached.
      Throws:
        `java.io.IOException` - - if an I/O error occurs.

    - #### reset

          public void reset()

      Repositions this stream to the position at the time the mark method was last called on this input stream.
      Overrides:
        `reset` in class `java.io.InputStream`

    - #### skip

          public long skip(long n)
                    throws java.io.IOException

      Skips over and discards n bytes of data from this input stream.
      Overrides:
        `skip` in class `java.io.InputStream`
      Throws:
        `java.io.IOException`

Copyright © 2025 MarkLogic Corporation. All Rights Reserved.

Complete online documentation for MarkLogic Server, XQuery and related components may be found at developer.marklogic.com