Class ByteArrayStreamingContent

java.lang.Object
com.google.api.client.util.ByteArrayStreamingContent
All Implemented Interfaces:
StreamingContent

public class ByteArrayStreamingContent extends Object implements StreamingContent
Streaming content whose source is a byte array.

Implementation is not thread-safe.

Since:
1.14
  • Field Details

    • byteArray

      private final byte[] byteArray
      Byte array content.
    • offset

      private final int offset
      Starting offset into the byte array.
    • length

      private final int length
      Length of bytes to read from byte array.
  • Constructor Details

    • ByteArrayStreamingContent

      public ByteArrayStreamingContent(byte[] byteArray)
      Parameters:
      byteArray - byte array content
    • ByteArrayStreamingContent

      public ByteArrayStreamingContent(byte[] byteArray, int offset, int length)
      Parameters:
      byteArray - byte array content
      offset - starting offset into the byte array
      length - of bytes to read from byte array
  • Method Details

    • writeTo

      public void writeTo(OutputStream out) throws IOException
      Description copied from interface: StreamingContent
      Writes the byte content to the given output stream.

      Implementations must not close the output stream, and instead should flush the output stream. Some callers may assume that the the output stream has not been closed, and will fail to work if it has been closed.

      Specified by:
      writeTo in interface StreamingContent
      Parameters:
      out - output stream
      Throws:
      IOException