java - CXF, XMLStreamWriter and Encoding -


i have spring web project should implemented cxf , web services.

one function output xml file. using xmlstreamwriter task. works fine.

but when add cxf dependencies pom-file, output xml file gets "ibm1252" encoding. xml file can not read afterwards. exception: "invalid encoding name ibm1252" thrown.

i have added following dependencies:

 <dependency> <groupid>org.apache.cxf</groupid> <artifactid>cxf-rt-core</artifactid> <version>${cxf.version}</version> </dependency> <dependency> <groupid>org.apache.cxf</groupid> <artifactid>cxf-rt-frontend-jaxws</artifactid> <version>${cxf.version}</version> </dependency> <dependency> <groupid>org.apache.cxf</groupid> <artifactid>cxf-rt-transports-http</artifactid> <version>${cxf.version}</version> </dependency> 

i didn't change in code. , have tried this:

 xmlstreamwriter writer = facout.createxmlstreamwriter(filewriter); writer.writestartdocument("utf-8", "1.0"); 

i still "ibm1252" encoding.

does have idea reason it?

instead of using filewriter, uses system default encoding, use outputstreamwriter.

like so

 outputstream os=null; writer filewriter = null; file f=new file("myfile"); try { os =new fileoutputstream(f); filewriter =new outputstreamwriter(os,"utf-8"); } { // close writer, outputstream if not null } 

....


Comments

Popular posts from this blog

JQuery Autocomplete without using label, value, id -

c++ - Accessing inactive union member and undefined behavior? -

JAVA - what is the difference between void and boolean methods? -