Real simple question really. I need to read a Unicode text file in a Java program.
I am used to using plain ASCII text with a BufferedReader FileReader combo which is obviously not working :(
I know that I can read a String in the 'traditional' way using a Buffered Reader and then convert it using something like:
temp = new String(temp.getBytes(), "UTF-16");
But is there a way to wrap the Reader in a 'Converter'?
EDIT: the file starts with FF FE
you wouldn't wrap the Reader, instead you would wrap the stream using an InputStreamReader. You could then wrap that with your BufferedReader that you currently use
BufferedReader in = new BufferedReader(new InputStreamReader(stream, encoding));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With