public final class Read
extends java.lang.Object
Modifier and Type | Method and Description |
---|---|
static int |
readBytesBlocking(java.io.InputStream in,
byte[] b,
int off,
int len,
int timeoutInMillis)
Reads exactly len bytes from the input stream into the byte array.
|
static java.lang.String |
readStringBlocking(java.io.InputStream is,
int estimatedLength,
long timeoutInMillis,
boolean gzipped,
java.nio.charset.Charset charSet)
Used to read until EOF on an InputStream that sometimes returns 0 bytes because data have not arrived yet.
|
public static int readBytesBlocking(java.io.InputStream in, byte[] b, int off, int len, int timeoutInMillis) throws java.io.IOException
in
- stream to readb
- the buffer into which the data is read.off
- the start offset of the data in the array, not offset into the file!len
- the number of bytes to read.timeoutInMillis
- give up after this amount of time.java.io.IOException
- if an I/O error occurs, usually a timeout.public static java.lang.String readStringBlocking(java.io.InputStream is, int estimatedLength, long timeoutInMillis, boolean gzipped, java.nio.charset.Charset charSet) throws java.io.IOException
is
- InputStream to read from.estimatedLength
- Estimated number of bytes that will be read. -1 or 0 mean you have no idea. Best to
make some sort of guess a little on the high side.timeoutInMillis
- give up after this amount of time.gzipped
- true if the bytes are compressed with gzip. Request decompression.charSet
- The encoding of the byte stream. readStringBlocking converts to a standard Unicode-16
String. usually UTF-8 or ISO-8859-1.java.io.IOException
- if connection lost, timeout etc., possibly UnsupportedEncodingException If the named charset
is not supported