org.inria.ns.reflex.xml.provider.xom
Class EncodingHeuristics

java.lang.Object
  extended by org.inria.ns.reflex.xml.provider.xom.EncodingHeuristics

public class EncodingHeuristics
extends Object

EncodingHeuristics reads from a stream (which should be buffered) and attempts to guess what the encoding of the text in the stream is. Byte order marks are stripped from the stream. If it fails to determine the type of the encoding, it returns the default UTF-8.

Updates

This class is a copy of the class nu.xom.xinclude.EncodingHeuristics from XOM. What differs is the name of the package it belongs, and above all its modifier, which becomes public.

Version:
1.0
Author:
Elliotte Rusty Harold

Method Summary
static String readEncodingFromStream(InputStream in)
           This utility method uses a variety of heuristics to attempt to guess the encoding from the initial characters.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

readEncodingFromStream

public static String readEncodingFromStream(InputStream in)
                                     throws IOException

This utility method uses a variety of heuristics to attempt to guess the encoding from the initial characters.

Parameters:
in - InputStream to read from.
Returns:
String The name of the encoding.
Throws:
IOException - if the stream cannot be reset back to where it was when the method was invoked.