Modifier and Type | Class and Description |
---|---|
private static class |
DataUtil.BomCharset |
Modifier and Type | Field and Description |
---|---|
(package private) static int |
boundaryLength |
(package private) static int |
bufferSize |
private static Pattern |
charsetPattern |
(package private) static String |
defaultCharset |
private static int |
firstReadBufferSize |
private static char[] |
mimeBoundaryChars |
Modifier | Constructor and Description |
---|---|
private |
DataUtil() |
Modifier and Type | Method and Description |
---|---|
(package private) static void |
crossStreams(InputStream in,
OutputStream out)
Writes the input stream to the output stream.
|
private static DataUtil.BomCharset |
detectCharsetFromBom(ByteBuffer byteData) |
(package private) static ByteBuffer |
emptyByteBuffer() |
(package private) static String |
getCharsetFromContentType(String contentType)
Parse out a charset from a content type header.
|
static Document |
load(File in,
String charsetName,
String baseUri)
Loads 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.
|
(package private) static String |
mimeBoundary()
Creates a random string, suitable for use as a mime boundary
|
(package private) static Document |
parseInputStream(InputStream input,
String charsetName,
String baseUri,
Parser parser) |
(package private) static ByteBuffer |
readFileToByteBuffer(File file) |
(package private) static ByteBuffer |
readToByteBuffer(InputStream inStream) |
static ByteBuffer |
readToByteBuffer(InputStream inStream,
int maxSize)
Read the input stream into a byte buffer.
|
private static String |
validateCharset(String cs) |
private static final Pattern charsetPattern
static final String defaultCharset
private static final int firstReadBufferSize
static final int bufferSize
private static final char[] mimeBoundaryChars
static final int boundaryLength
private DataUtil()
public static Document load(File in, String charsetName, String baseUri) throws IOException
in
- file to loadcharsetName
- character set of inputbaseUri
- base URI of document, to resolve relative links againstIOException
- on IO errorpublic static Document load(InputStream in, String charsetName, String baseUri) throws IOException
in
- input stream to parse. You will need to close it.charsetName
- character set of inputbaseUri
- base URI of document, to resolve relative links againstIOException
- on IO errorpublic static Document load(InputStream in, String charsetName, String baseUri, Parser parser) throws IOException
in
- input stream to parse. You will need to close it.charsetName
- character set of inputbaseUri
- base URI of document, to resolve relative links againstparser
- alternate parser
to use.IOException
- on IO errorstatic void crossStreams(InputStream in, OutputStream out) throws IOException
in
- input stream to read fromout
- output stream to write toIOException
- on IO errorstatic Document parseInputStream(InputStream input, String charsetName, String baseUri, Parser parser) throws IOException
IOException
public 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.static ByteBuffer readToByteBuffer(InputStream inStream) throws IOException
IOException
static ByteBuffer readFileToByteBuffer(File file) throws IOException
IOException
static ByteBuffer emptyByteBuffer()
static String getCharsetFromContentType(String contentType)
contentType
- e.g. "text/html; charset=EUC-JP"private static String validateCharset(String cs)
static String mimeBoundary()
private static DataUtil.BomCharset detectCharsetFromBom(ByteBuffer byteData)
WebARTS Library Licensed Under the GNU - General Public License. Other Libraries licensed under their respective Open Source Licenses