Package dev.enola.common.io.mediatype
Class ResourceCharsetDetectorSPI
java.lang.Object
dev.enola.common.io.mediatype.ResourceCharsetDetectorSPI
- All Implemented Interfaces:
ResourceCharsetDetector
- Direct Known Subclasses:
YamlMediaType
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondetectCharset(URI uri, ByteSource source) Detect theCharsetby "sniffing" the source e.g.protected final byte[]peek(int n, URI uri, ByteSource source) Peeks at the first N bytes of a resource.
-
Constructor Details
-
ResourceCharsetDetectorSPI
public ResourceCharsetDetectorSPI()
-
-
Method Details
-
detectCharset
Description copied from interface:ResourceCharsetDetectorDetect theCharsetby "sniffing" the source e.g. for "BOM detection". The URI argument is only uses for error messages. (It's never "accessed".)- Specified by:
detectCharsetin interfaceResourceCharsetDetector
-
peek
Peeks at the first N bytes of a resource.- Returns:
- byte array of length up to N bytes, or shorter if the resource had less bytes, or there was an error reading from it
-