Package org.jsoup.helper
Class DataUtil
- java.lang.Object
-
- org.jsoup.helper.DataUtil
-
public final class DataUtil extends java.lang.ObjectInternal static utilities for handling data.
-
-
Field Summary
Fields Modifier and Type Field Description static java.nio.charset.CharsetUTF_8
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Documentload(java.io.File file, java.lang.String charsetName, java.lang.String baseUri)Loads and parses a file to a Document, with the HtmlParser.static Documentload(java.io.File file, java.lang.String charsetName, java.lang.String baseUri, Parser parser)Loads and parses a file to a Document.static Documentload(java.io.InputStream in, java.lang.String charsetName, java.lang.String baseUri)Parses a Document from an input steam.static Documentload(java.io.InputStream in, java.lang.String charsetName, java.lang.String baseUri, Parser parser)Parses a Document from an input steam, using the provided Parser.static java.nio.ByteBufferreadToByteBuffer(java.io.InputStream inStream, int maxSize)Read the input stream into a byte buffer.
-
-
-
Method Detail
-
load
public static Document load(java.io.File file, @Nullable java.lang.String charsetName, java.lang.String baseUri) throws java.io.IOException
Loads and parses a file to a Document, with the HtmlParser. Files that are compressed with gzip (and end in.gzor.z) are supported in addition to uncompressed files.- Parameters:
file- file to loadcharsetName- (optional) character set of input; specifynullto attempt to autodetect. A BOM in the file will always override this setting.baseUri- base URI of document, to resolve relative links against- Returns:
- Document
- Throws:
java.io.IOException- on IO error
-
load
public static Document load(java.io.File file, @Nullable java.lang.String charsetName, java.lang.String baseUri, Parser parser) throws java.io.IOException
Loads and parses a file to a Document. Files that are compressed with gzip (and end in.gzor.z) are supported in addition to uncompressed files.- Parameters:
file- file to loadcharsetName- (optional) character set of input; specifynullto attempt to autodetect. A BOM in the file will always override this setting.baseUri- base URI of document, to resolve relative links againstparser- alternateparserto use.- Returns:
- Document
- Throws:
java.io.IOException- on IO error- Since:
- 1.14.2
-
load
public static Document load(java.io.InputStream in, @Nullable java.lang.String charsetName, java.lang.String baseUri) throws java.io.IOException
Parses a Document from an input steam.- Parameters:
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 against- Returns:
- Document
- Throws:
java.io.IOException- on IO error
-
load
public static Document load(java.io.InputStream in, @Nullable java.lang.String charsetName, java.lang.String baseUri, Parser parser) throws java.io.IOException
Parses a Document from an input steam, using the provided Parser.- Parameters:
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- alternateparserto use.- Returns:
- Document
- Throws:
java.io.IOException- on IO error
-
readToByteBuffer
public static java.nio.ByteBuffer readToByteBuffer(java.io.InputStream inStream, int maxSize) throws java.io.IOExceptionRead the input stream into a byte buffer. To deal with slow input streams, you may interrupt the thread this method is executing on. The data read until being interrupted will be available.- Parameters:
inStream- the input stream to read frommaxSize- the maximum size in bytes to read from the stream. Set to 0 to be unlimited.- Returns:
- the filled byte buffer
- Throws:
java.io.IOException- if an exception occurs whilst reading from the input stream.
-
-