StringBuffer contents=new StringBuffer();
BufferedReader input = new BufferedReader(new FileReader(\"/home/xyz/abc.txt\"));
String line = null; //not declared withi
You should store the contents in the file as UTF-8
encoded Hindi characters. For instance, in your case it would be अभी समय है जनता जो चाहती है
. That is, instead of saving unicode escapes, directly save the raw Hindi characters. You can then simply read like normal.
You just have to make sure that the editor you use saves it using UTF-8 encoding. See Spanish language chars are not displayed properly?
Otherwise, you'll have to make the file a .properties
file and read using java.util.Properties
as it offers unicode unescaping support inherently.
Also read Reading unicode character in java