Skip to Content
0
Jan 21, 2014 at 10:08 AM

Adding BOM at beginning of the file in receiver side .txt file

127 Views

Hi all,

I want to generate .txt file at receiver with file format UTF-16LE & BOM( beginning of the file).

for this i have written below logic in my custom adapter module, but i was generating file without BOM.

Could you please help me.It's very urgent.

//Read XML from payload

// Adding BOM to output stream
byte[] BOMByte = {(byte)0xFF,(byte)0xFF};
out.write(BOMByte);
TransformerFactory transformerFactory = TransformerFactory.newInstance();

Transformer transformer = transformerFactory.newTransformer();

//Converting into UTF-16LE Format.

transformer.setOutputProperty("encoding", "UTF-16LE");
Result result = new StreamResult(out);

Regards,

Satish