public class InputStreamHelper extends Object
Constructor and Description |
---|
InputStreamHelper() |
Modifier and Type | Method and Description |
---|---|
static byte[] |
read(InputStream is,
byte[] data)
Read bytes from the input stream to fill the provided array.
|
static byte[] |
read(InputStream is,
byte[] data,
int size)
Read bytes from the input stream to fill the provided array.
|
static byte[] |
read(InputStream is,
int size)
Reads a specified number of bytes from the input stream and populates
a new byte array.
|
static byte[] |
readAvailable(InputStream is)
Reda the available bytes from the input stream and populate
a new byte array.
|
static void |
skip(InputStream stream,
long skip)
The documentation for
InputStream.skip indicates that it can bail out early, and not skip
the requested number of bytes. |
static File |
writeStreamToTempFile(InputStream inputStream,
String tempFileSuffix)
Copy the data from an InputStream to a temp file.
|
static File |
writeZipStreamToTempDir(InputStream inputStream)
Expands a zip file input stream into a temporary directory.
|
public static File writeStreamToTempFile(InputStream inputStream, String tempFileSuffix) throws IOException
inputStream
- data sourcetempFileSuffix
- suffix to use for temp fileIOException
public static File writeZipStreamToTempDir(InputStream inputStream) throws IOException
inputStream
- zip file input streamIOException
public static byte[] readAvailable(InputStream is) throws IOException
is
- InputStream instanceIOException
public static byte[] read(InputStream is, int size) throws IOException
is
- InputStream instancesize
- number of bytes to readIOException
public static byte[] read(InputStream is, byte[] data) throws IOException
is
- InputStream instancedata
- array to fillIOException
public static byte[] read(InputStream is, byte[] data, int size) throws IOException
is
- InputStream instancedata
- array to fillsize
- number of bytes to readIOException
public static void skip(InputStream stream, long skip) throws IOException
InputStream.skip
indicates that it can bail out early, and not skip
the requested number of bytes. I've encountered this in practice, hence this helper method.stream
- InputStream instanceskip
- number of bytes to skipIOException
Copyright © 2000–2024 Packwood Software. All rights reserved.