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.

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.

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.