Package net.sf.saxon.resource
Class EncodingDetector
java.lang.Object
net.sf.saxon.resource.EncodingDetector
Utility class to detect the encoding of a stream by examining the initial bytes
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic String
inferStreamEncoding
(InputStream is, String defaultEncoding, Logger err) Try to detect the encoding from the start of the input stream
-
Constructor Details
-
EncodingDetector
public EncodingDetector()
-
-
Method Details
-
inferStreamEncoding
public static String inferStreamEncoding(InputStream is, String defaultEncoding, Logger err) throws IOException Try to detect the encoding from the start of the input stream- Parameters:
is
- the input streamdefaultEncoding
- the fallback encoding, normally UTF-8err
- logger to be used for diagnostics, or null- Returns:
- the inferred encoding, defaulting to UTF-8
- Throws:
IOException
- if it isn't possible to mark the current position on the input stream and read ahead
-