File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Writing byte array to xml in Java

 
Luqman Qaiser
Greenhorn
Posts: 18
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

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?

Thanks.
 
Paul Clapham
Sheriff
Pie
Posts: 20161
23
MySQL Database
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Greenhorn
Posts: 18
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

Thanks
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic