This method of the Document class retrieves the character encoding information.
public final String getEncoding();
Returns the encoding information stored in the <?XML ...?> tag or the user-defined output encoding if it has been more recently set.