I need to parse a csv file, whose encoding format is in utf-16 format. Actually the csv file contains the list of directories to the file. for reading i used following code

BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(str)));

But the output i got is not in the correct format however i got all the data and if i write following code

BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(str), "utf-16"));

the same code i did previously couldnt give all the data. I hope u understood what i meant. need help.

Edited 3 Years Ago by mike_2000_17: Fixed formatting

same code i did previously couldnt give all the data

Sorry, I don't understand what you mean.
Do you mean that you did not read all the data in the file with the second code?
How much did you read? Compare that with how much was read with the first code.


For testing purposes:
Can you make a simple program that writes a UTF-16 file and then reads it in and displays its contents.

Edited 5 Years Ago by NormR1: n/a

Yes actually. The problem is in parsing a UTF-16 encoded file. Is the procedure any different than parsing the UTF-8 encoded file.

The parsing of the data would be the same once it has been read into String variables in the program. You would use different encodings/charsets when reading the file.

This question has already been answered. Start a new discussion instead.