Package htsjdk.samtools.cram.io
Class InputStreamUtils
- java.lang.Object
-
- htsjdk.samtools.cram.io.InputStreamUtils
-
public class InputStreamUtils extends Object
Convenience methods to read fromInputStream
.
-
-
Constructor Summary
Constructors Constructor Description InputStreamUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static byte[]
readFully(InputStream input)
Read theInputStream
until the end into a new byte array.static void
readFully(InputStream inputStream, byte[] b, int off, int length)
Read the specified number of bytes from theInputStream
into the byte array starting from the specified position.static byte[]
readFully(InputStream inputStream, int length)
Read the specified number of bytes from theInputStream
into a new byte array.static void
skipFully(InputStream in, long length)
Skip the specified number of bytes from theInputStream
.
-
-
-
Method Detail
-
readFully
public static byte[] readFully(InputStream input)
Read theInputStream
until the end into a new byte array.- Parameters:
input
- the input stream to read- Returns:
- a new byte array containing data from the input stream
-
readFully
public static byte[] readFully(InputStream inputStream, int length) throws IOException
Read the specified number of bytes from theInputStream
into a new byte array. The length of the array is less or equal to length.- Parameters:
inputStream
- the input stream to read fromlength
- the number of bytes to read- Returns:
- a new byte array containing data from the input stream
- Throws:
IOException
- as per java IO contractEOFException
- if there is less than length bytes in the stream
-
readFully
public static void readFully(InputStream inputStream, byte[] b, int off, int length) throws IOException
Read the specified number of bytes from theInputStream
into the byte array starting from the specified position. The length of the array is less or equal to length.- Parameters:
inputStream
- the input stream to read fromb
- the byte array to read intooff
- offset in the byte arraylength
- the number of bytes to read- Throws:
IOException
- as per java IO contractEOFException
- if there is less than length bytes in the stream
-
skipFully
public static void skipFully(InputStream in, long length) throws IOException
Skip the specified number of bytes from theInputStream
.- Parameters:
in
- the input stream to skip bytes fromlength
- the number of bytes to skip- Throws:
IOException
- as per java IO contractEOFException
- if there is less than length bytes in the stream
-
-