jQuery in Action, 3rd edition
The moose likes XML and Related Technologies and the fly likes Writing byte array to xml in Java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Writing byte array to xml in Java" Watch "Writing byte array to xml in Java" New topic

Writing byte array to xml in Java

Luqman Qaiser

Joined: Aug 21, 2005
Posts: 18

The data (Byte array)that i am trying to write to xml is changing when am converting it to string , so Is it possible to write byte array as it is to xml file without converting it to string?

Paul Clapham

Joined: Oct 14, 2005
Posts: 19973

Probably not, although it depends on what is in your byte array and what you mean by "changing".

XML is a text format. It is not meant to contain arbitrary bytes, and in fact it is specifically not allowed for XML documents to contain bytes in the range x'00' to x'1f' (with the exception of tab, line feed, and carriage return characters). So if your byte array contains bytes that don't map to printable characters, you will have to do something else to get it into an XML document. Encoding the bytes using Base64 is a popular method, for example.
Luqman Qaiser

Joined: Aug 21, 2005
Posts: 18
You mean after encoding it, the value then written as string to xml would be equivalent to byte data?

The scenario related To websphere MQ ,the messageID generated by MQSeries for request message is to be written in xml so that later this message id can be retrived from xml and response message can be put...

In that case the requester will check the request message id and response message id to retrive the response message from queue.

I agree. Here's the link: http://aspose.com/file-tools
subject: Writing byte array to xml in Java
It's not a secret anymore!