public final class IOUtil extends Object
Modifier and Type | Method and Description |
---|---|
static byte[] |
borrowBytes(InputStream is,
int qty)
Gets and resets the specified number of bytes from the input stream.
|
static String[] |
head(InputStream is,
Charset encoding,
int lineQty)
Gets the first lines from an input stream, using the specified encoding.
|
static String[] |
head(InputStream is,
int lineQty)
Gets the first lines from an input stream, using UTF-8.
|
static String[] |
head(InputStream is,
String encoding,
int lineQty)
Gets the first lines from an input stream, using the specified encoding.
|
static boolean |
startsWith(InputStream is,
byte[] bytes)
Whether the given input stream starts the specified bytes array
or not.
|
static String[] |
tail(InputStream is,
Charset encoding,
int lineQty)
Gets the last lines from an input stream, using the specified encoding.
|
static String[] |
tail(InputStream is,
int lineQty)
Gets the last lines from an input stream, using UTF-8.
|
static String[] |
tail(InputStream is,
String encoding,
int lineQty)
Gets the last lines from an input stream, using the specified encoding.
|
static BufferedInputStream |
toBufferedInputStream(InputStream in)
Wraps the input stream in a
BufferedInputStream if not a subclass
already. |
static BufferedReader |
toBufferedReader(Reader reader)
Wraps the reader in a
BufferedReader if not a subclass already. |
public static boolean startsWith(InputStream is, byte[] bytes) throws IOException
false
is returned.is
- input streambytes
- byte array to comparetrue
if input stream starts with byte arrayIOException
- if InputStream.markSupported()
returns falsepublic static byte[] borrowBytes(InputStream is, int qty) throws IOException
is
- input streamqty
- number of bytes to readIOException
- if InputStream.markSupported()
returns falsepublic static BufferedReader toBufferedReader(Reader reader)
BufferedReader
if not a subclass already.reader
- the reader to wrap if neededpublic static BufferedInputStream toBufferedInputStream(InputStream in)
BufferedInputStream
if not a subclass
already.in
- the input stream to wrap if neededpublic static String[] tail(InputStream is, int lineQty) throws IOException
FileUtil.tail(
java.io.File, int)
instead, which can read
a file starting from the end.is
- input streamlineQty
- maximum number of lines to returnIOException
- problem reading linespublic static String[] tail(InputStream is, String encoding, int lineQty) throws IOException
FileUtil.tail(
File, String, int)
instead, which can read
a file starting from the end.is
- input streamencoding
- character encodinglineQty
- maximum number of lines to returnIOException
- problem reading linespublic static String[] tail(InputStream is, Charset encoding, int lineQty) throws IOException
FileUtil.tail(
File, String, int)
instead, which can read
a file starting from the end.is
- input streamencoding
- character encodinglineQty
- maximum number of lines to returnIOException
- problem reading linespublic static String[] head(InputStream is, int lineQty) throws IOException
is
- input streamlineQty
- maximum number of lines to returnIOException
- problem reading linespublic static String[] head(InputStream is, String encoding, int lineQty) throws IOException
is
- input streamencoding
- character encodinglineQty
- maximum number of lines to returnIOException
- problem reading linespublic static String[] head(InputStream is, Charset encoding, int lineQty) throws IOException
is
- input streamencoding
- character encodinglineQty
- maximum number of lines to returnIOException
- problem reading linesCopyright © 2008–2021 Norconex Inc.. All rights reserved.