Reputation: 9508
I have some Java code that writes to a text file, specifying UTF-8 as encoding.
Now, some of the files written contain a <U+FEFF>
character at the very start, which creates a mess for other programs that use the file.
I can't change the behavior of the other programs, and I can't post-process files externally since they may be on another machine.
Is there any way to write the file without adding this character to the start?
Upvotes: 1
Views: 1753
Reputation: 74750
Java should not add this character to UTF-8 files, only when writing UTF-16 (when not UTF-16LE or UTF-16BE is specified). So, it seems this character was already in your data you output. So, simply check the first character to be written and if it is the BOM, leave it away.
If this does not help, you have to show your code.
Upvotes: 3