Java String contains extraneous data

I have an input that is encoded in UTF16LE. By the time this input reaches my code, it was through a FileInputStream wrapped in a FileReader wrapped in a LineNumberReader string.

The first line reads a line like:

"1 piece of data like a string"

However, looking at this line, the value will look like this:

[, 1, p, i, ...]

Note the launch of an empty element.

No, this line is passed through a couple of functions here and there, converted to Object and basically goes through its steps. At some point, which should only be the first part of String (1 or in my case any number, including decimal numbers), a function is passed that must parse it to the actual number.

The contents of this line look like "1", but in the value that it says:   

[, 1, p, i, ...]

so the whole line is still there.

In any case, it returns ParseException, and I print an unverifiable number in the exception messages, and my journal tells me that "1" is an unsurpassed number.

The real problem seems to be the leading empty element, since the following lines show similar behavior, except for the leading empty element, and they analyze.

+3
source share
2 answers

, . UTF16LE. UTF16LE auto char. - utf16 . , UTF16LE, , LE.

0

A String ( , OpenJDK) char[], . String char[] offset offset+count.

, char[] , String.

, char[] String.

, String foobar, .substring(3) , String bar, char[], String offset, 3 , String a count, 3 .

, String : String char[] - , .

, String . , String character-for-character, - toCharArray() charAt() .

+2

Source: https://habr.com/ru/post/1790972/


All Articles