Pan
Pan

Reputation: 6645

Byte order mark removal in xml files using Java IO

The byte order mark is the first 3 bytes in my xml file. How do I remove the Byte order mark from the xml file programmatically? I want to completely discard it.

Upvotes: 0

Views: 924

Answers (1)

Jarek Potiuk
Jarek Potiuk

Reputation: 20067

Rather than removing it, I use a special reader which reacts properly to BOM (and uses proper encoding, based on read BOM): I copied it from elsewhere (see note inside) but it is open-sourced in my android-menu-navigator project:

http://code.google.com/p/android-menu-navigator/source/browse/src/pl/polidea/navigator/UnicodeReader.java

You can use this reader anyway to read content of XML and write it elsewhere, effectively removing the BOM.

Upvotes: 1

Related Questions