How to read UTF 8 encoded file in java with turkish characters

后端 未结 3 1460

I am trying to read a UTF-8 encoded txt file, which has some turkish characters. Basically I am have written an axis based web service, which reads this file and send the ou

3条回答
  •  天命终不由人
    2020-12-07 04:32

    You appear to be correctly decoding the file data from UTF-8 to UTF-16 strings.

    System.out performs transcoding operations from UTF-16 strings to the default JRE character encoding. If this does not match the encoding used by the device receiving the character data is corrupted. So, the console should be set to the default character encoding or data corruption occurs. How this is done is device-dependent.

    If you are using a terminal, the Console does a better job of determining the device encoding.

    Note: it is better to use the try-with-resources or at least try-finally to close streams; use the standard encoding constants if available.

提交回复
热议问题