Class StreamUtils

java.lang.Object
fr.gouv.vitam.common.stream.StreamUtils

public class StreamUtils extends Object
This class supports Helpers on streams.
  • Method Details

    • copy

      public static final long copy(InputStream inputStream, OutputStream outputStream) throws IOException
      Copy InputStream to OutputStream efficiently

      InputStream will be closed, but not the OutputStream in order to be compatible with StreamingOutput
      Parameters:
      inputStream -
      outputStream -
      Returns:
      the copied length
      Throws:
      IOException
    • closeSilently

      public static final long closeSilently(InputStream inputStream)
      Close silently the InputStream, first consuming any bytes available, ignoring IOException or null object.
      Parameters:
      inputStream -
      Returns:
      the length in bytes that were read before closing
    • getRemainingReadOnCloseInputStream

      public static final InputStream getRemainingReadOnCloseInputStream(InputStream inputStream)
      Build an InputStream over the source one that will consume any left data when closing it.
      Parameters:
      inputStream -
      Returns:
      the new InputStream to use
    • toString

      public static final String toString(InputStream inputStream) throws IOException
      Parameters:
      inputStream -
      Returns:
      the corresponding String from InputStream
      Throws:
      IOException
    • toInputStream

      public static InputStream toInputStream(String source)
      Parameters:
      source -
      Returns:
      the corresponding InputStream
    • contentEquals

      public static boolean contentEquals(InputStream is1, InputStream is2)
      Parameters:
      is1 -
      is2 -
      Returns:
      True if equals
    • consumeAnyEntityAndClose

      public static void consumeAnyEntityAndClose(javax.ws.rs.core.Response response)
      This method consume everything (in particular InpuStream) and close the response.
      Parameters:
      response -
    • closeSilently

      public static void closeSilently(Channel channel)