public final class DataUtil extends Object
| Modifier and Type | Method and Description |
|---|---|
static Document |
load(File file,
String charsetName,
String baseUri)
Loads and parses a file to a Document, with the HtmlParser.
|
static Document |
load(File file,
String charsetName,
String baseUri,
Parser parser)
Loads and parses a file to a Document.
|
static Document |
load(InputStream in,
String charsetName,
String baseUri)
Parses a Document from an input steam.
|
static Document |
load(InputStream in,
String charsetName,
String baseUri,
Parser parser)
Parses a Document from an input steam, using the provided Parser.
|
static ByteBuffer |
readToByteBuffer(InputStream inStream,
int maxSize)
Read the input stream into a byte buffer.
|
public static final Charset UTF_8
public static Document load(File file, @Nullable String charsetName, String baseUri) throws IOException
.gz or .z)
are supported in addition to uncompressed files.file - file to loadcharsetName - (optional) character set of input; specify null to attempt to autodetect. A BOM in
the file will always override this setting.baseUri - base URI of document, to resolve relative links againstIOException - on IO errorpublic static Document load(File file, @Nullable String charsetName, String baseUri, Parser parser) throws IOException
.gz or .z)
are supported in addition to uncompressed files.file - file to loadcharsetName - (optional) character set of input; specify null to attempt to autodetect. A BOM in
the file will always override this setting.baseUri - base URI of document, to resolve relative links againstparser - alternate parser to use.IOException - on IO errorpublic static Document load(InputStream in, @Nullable String charsetName, String baseUri) throws IOException
in - input stream to parse. The stream will be closed after reading.charsetName - character set of input (optional)baseUri - base URI of document, to resolve relative links againstIOException - on IO errorpublic static Document load(InputStream in, @Nullable String charsetName, String baseUri, Parser parser) throws IOException
in - input stream to parse. The stream will be closed after reading.charsetName - character set of input (optional)baseUri - base URI of document, to resolve relative links againstparser - alternate parser to use.IOException - on IO errorpublic static ByteBuffer readToByteBuffer(InputStream inStream, int maxSize) throws IOException
inStream - the input stream to read frommaxSize - the maximum size in bytes to read from the stream. Set to 0 to be unlimited.IOException - if an exception occurs whilst reading from the input stream.Copyright © 2009–2025 Jonathan Hedley. All rights reserved.