Class Streams

java.lang.Object
org.elasticsearch.core.internal.io.Streams

public class Streams
extends java.lang.Object
Simple utility methods for file and stream copying. All copy methods use a block size of 4096 bytes, and close all affected streams when done.

Mainly for use within the framework, but also useful for application code.

  • Method Summary

    Modifier and Type Method Description
    static long copy​(java.io.InputStream in, java.io.OutputStream out)  
    static long copy​(java.io.InputStream in, java.io.OutputStream out, boolean close)  
    static long copy​(java.io.InputStream in, java.io.OutputStream out, byte[] buffer)  
    static long copy​(java.io.InputStream in, java.io.OutputStream out, byte[] buffer, boolean close)
    Copy the contents of the given InputStream to the given OutputStream.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • copy

      public static long copy​(java.io.InputStream in, java.io.OutputStream out, byte[] buffer, boolean close) throws java.io.IOException
      Copy the contents of the given InputStream to the given OutputStream. Optionally, closes both streams when done.
      Parameters:
      in - the stream to copy from
      out - the stream to copy to
      close - whether to close both streams after copying
      buffer - buffer to use for copying
      Returns:
      the number of bytes copied
      Throws:
      java.io.IOException - in case of I/O errors
    • copy

      public static long copy​(java.io.InputStream in, java.io.OutputStream out, boolean close) throws java.io.IOException
      Throws:
      java.io.IOException
      See Also:
      copy(InputStream, OutputStream, byte[], boolean)
    • copy

      public static long copy​(java.io.InputStream in, java.io.OutputStream out, byte[] buffer) throws java.io.IOException
      Throws:
      java.io.IOException
      See Also:
      copy(InputStream, OutputStream, byte[], boolean)
    • copy

      public static long copy​(java.io.InputStream in, java.io.OutputStream out) throws java.io.IOException
      Throws:
      java.io.IOException
      See Also:
      copy(InputStream, OutputStream, byte[], boolean)