I have an input which is in UTF16LE encoding. By the time this input reaches my code its been through a FileInputStream encased in a FileReader encased in a LineNumberReader.
The first line read gives a string like:
"1 piece of data like a string"
However, looking into this String the value will be something along the lines of:
[, 1, p, i, ...]
Notice the empty element to start.
No this string is passed through a couple of functions here and there, converted to Object and basically is being put through its paces. At a certain point, what should only be the first part of the String (the 1 or in my case any number including with decimals) is passed to a function which has to parse it to an actual Number.
The content of this String appears to be "1" but in the value it says:
[, 1, p, i, ...]
so the whole string is still in there.
In any case it returns a ParseException and I print the unparseable number to an exception messages and my logging tels me that “1” is an unparseable number.
The real problem appears to be the leading empty element as subsequent lines show similar behavior except for the leading empty element and they parse.
I think I have the answer. The encoding was not UTF16LE. It was set to UTF16LE by an auto char detection algorithm. The encoding is utf16 with a BOM. However since the various classes thought the encoding was UTF16LE they were not getting rid of the BOM which shouldn’t be there in the LE version.