-3
byte[] data;
ResultSet resultSet 
data = resultSet.getBytes("xml");//It is XML of ANSI type from database(ms-sql);

I am trying to convert XML to UTF-8 type.

Please help me figure this out.

fromstog
  • 9
  • 5
  • possible duplicate of http://stackoverflow.com/questions/443305/producing-valid-xml-with-java-and-utf-8-encoding?rq=1 – Aaron Brager Jan 09 '14 at 02:16

2 Answers2

0

You might use the constructor of String that takes an encoding; for example, new String(data, "UTF-8");

It's probably easiest to just call resultSet.getString("xml");

Elliott Frisch
  • 198,278
  • 20
  • 158
  • 249
0

You probably should just feed the bytes directly to an XML parser. XML almost requires the encoding to be specified, and the parser will figure it out on its own.

David Ehrmann
  • 7,366
  • 2
  • 31
  • 40