• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Jeanne Boyarsky
  • Tim Cooke
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Mikalai Zaikin
  • Carey Brown
Bartenders:

Writing byte array to xml in Java

 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Marshal
Posts: 27996
94
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
To do a great right, do a little wrong - shakepeare. twisted little ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic