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
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.
Code looks good. The problem should be in console output that cannot print Turkish. To be sure make a temp test in your program: take the string with Assal?τ????÷÷?? that you read from file and do this
System.out.println(str.charAt(6) == 'ğ');
Make sure the console you use to display the output is also encoded in UTF-8. In Eclipse for example, you need to go to Run Configuration
> Common
to do this.