Package fr.gouv.vitam.common.stream
Class StreamUtils
java.lang.Object
fr.gouv.vitam.common.stream.StreamUtils
This class supports Helpers on streams.
-
Method Summary
Modifier and TypeMethodDescriptionstatic final long
closeSilently
(InputStream inputStream) Close silently the InputStream, first consuming any bytes available, ignoring IOException or null object.static void
closeSilently
(Channel channel) static void
consumeAnyEntityAndClose
(javax.ws.rs.core.Response response) This method consume everything (in particular InpuStream) and close the response.static boolean
contentEquals
(InputStream is1, InputStream is2) static final long
copy
(InputStream inputStream, OutputStream outputStream) Copy InputStream to OutputStream efficiently
InputStream will be closed, but not the OutputStream in order to be compatible with StreamingOutputstatic final InputStream
getRemainingReadOnCloseInputStream
(InputStream inputStream) Build an InputStream over the source one that will consume any left data when closing it.static InputStream
toInputStream
(String source) static final String
toString
(InputStream inputStream)
-
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
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
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
- Parameters:
inputStream
-- Returns:
- the corresponding String from InputStream
- Throws:
IOException
-
toInputStream
- Parameters:
source
-- Returns:
- the corresponding InputStream
-
contentEquals
- 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
-