Package org.forgerock.util
Class Streams
- java.lang.Object
-
- org.forgerock.util.Streams
-
public final class Streams extends Object
Utility methods for operating on IO streams.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static byte[]
readAtMost(InputStream in, int maximumSize)
Reads at most the given number of bytes from the input stream.
-
-
-
Method Detail
-
readAtMost
public static byte[] readAtMost(InputStream in, int maximumSize) throws IOException
Reads at most the given number of bytes from the input stream. The input stream is not closed after this operation, allowing the caller to determine if more bytes are still available. This method takes care not to allocate more storage than is necessary if the input stream may be significantly smaller than the maximum size.- Parameters:
in
- the input stream to read from.maximumSize
- the maximum number of bytes to read from the input stream.- Returns:
- the bytes read from the input stream.
- Throws:
IOException
- if an error occurs while reading the stream.
-
-