在使用StAX中,XMLStreamWriter.writeStartDocument()遇到的一个问题,求教!

最近在使用StAX的时候,看了很多资料,
XMLStreamWriter.writeStartDocument()有很多重载:
void writeStartDocument()
void writeStartDocument(String version)
void writeStartDocument(String encoding, String version)

在使用最后一个的时候就有问题了,
如果指定encoding,就可能会报错:
Exception in thread "main" javax.xml.stream.XMLStreamException: Underlying stream encoding 'GBK' and input paramter for writeStartDocument() method 'ISO-8859-1' do not match.

查找之后发现这个是与底层流编码不匹配的问题造成的。

StAX是一套接口,我现在所用的是JDK1.6_20里面的实现。
之前在工作里用的 bea 实现的就没有遇到过该问题。
请问有人遇到过这种问题么?
如果使用JDK1.6应该如何处理底层流编码呢?
附上源代码
[code="java"]
package com.yy.xml.stax.test;

import java.io.OutputStream;

import javax.xml.stream.XMLOutputFactory;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamWriter;

public class StAXTest {
public static void main(String[] args) throws XMLStreamException {
String ENCODING = "ISO-8859-1";
// Create an output factory
XMLOutputFactory xmlof = XMLOutputFactory.newInstance();
// Create an XML stream writer
XMLStreamWriter xmlw = xmlof.createXMLStreamWriter(System.out);
// Write XML prologue
//xmlw.writeStartDocument();
xmlw.writeStartDocument(ENCODING, "1.0");
}
}
[/code]

[quote]
Write the XML Declaration. Note that the encoding parameter does not set the actual encoding of the underlying output. [b]That must be set when the instance of the XMLStreamWriter is created using the XMLOutputFactory[/b]
[/quote]
writeStartDocument方法里说的明白,你采用下面的方式试试:
[code="java"]
String ENCODING = "ISO-8859-1";

// Create an output factory

XMLOutputFactory xmlof = XMLOutputFactory.newInstance();

// Create an XML stream writer

XMLStreamWriter xmlw = xmlof.createXMLStreamWriter(System.out , ENCODING);

// Write XML prologue

//xmlw.writeStartDocument();

xmlw.writeStartDocument(ENCODING, "1.0");

[/code]