----- Original Message -----
From: "Youngho Cho" <[EMAIL PROTECTED]>
> Hello,
>
> I would like to add
> <?xml version="1.0" encoding="UTF-8" ?>
> on the top of the beanwriter output.
>
> So I used .betwixt file like
>
> <?xml version="1.0" encoding="UTF-8" ?>
> <info>
> <addDefaults/>
> </info>

The encoding of the .betwixt file is a seperate thing to the encoding of the
output of BeanWriter. More below...


> Because I want to need just add <?xml version="1.0" encoding="UTF-8" ?>
> and the rest done by the Introspector.
>
> But I received java.lang.NullPointerException when I used .betwixt file
> ( If I didn't use .betwixt file than beanwriter make good xml file without
<?xml version="1.0" encoding="UTF-8" ?> )
>
> How do I add <?xml version="1.0" encoding="UTF-8" ?> easily ?

Right now BeanWriter doesn't actually output the XML declaration. This is
useful as it means you can embed the output of BeanWriter inside any text
file. It also means you can output any XML declaration yourself. e.g.


PrintWriter out = new PrintWriter( new FileWriter( "output.xml" ) );
out.println( "<?xml version='1.0' encoding='UTF-8' ?> " );
BeanWriter writer = new BeanWriter( out );
writer.write( mybean );


I've just added a couple of helper methods to make this kinda thing a bit
easier. So now with CVS HEAD you can do this...

BeanWriter writer = new BeanWriter( new FileWriter( "output.xml" );
writer.writeXmlDeclaration( "<?xml version='1.0' encoding='UTF-8' ?> " );
writer.write( mybean );
writer.close();

Which is a little easier to do and should be a little more obvious from the
javadoc.

http://jakarta.apache.org/commons/betwixt/apidocs/
http://jakarta.apache.org/commons/betwixt/apidocs/org/apache/commons/betwixt
/io/BeanWriter.html

James
-------
http://james.weblogger.com/

__________________________________________________
Do You Yahoo!?
Everything you'll ever need on one web page
from News and Sport to Email and Music Charts
http://uk.my.yahoo.com

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to