0
BufferedReader br=new BufferedReader( new InputStreamReader(new FileInputStream("g.txt"), "UTF-16"));
ArrayList<String> al=new ArrayList<String>();
String str;
while((str=br.readLine())!=null)
{
    al.add(str);
}
Iterator<String> it=al.iterator();
while(it.hasNext())
{
    str=it.next();
    System.out.println(str);
}

In this code I can read data from Unicode file properly and also able to insert into arrylist correctly but while I am trying to iterate the data It just print question marks only like ???? ?? ????, ?????, and so on can you help to solve this issu

G R
  • 11
  • 2

1 Answers1

0

This question has been answered on StackOverflow already and it has to do with System.out.println() using the default system codepage, not the set locale.

To print text using correct character encoding, create a new instance of PrintStream and use that to print your lines of text:

String text_containing_non_latin_characters = "...";
PrintStream ps = new PrintStream(System.out, true, "UTF-16");
ps.println(text_containing_non_latin_characters);
Community
  • 1
  • 1
klaar
  • 601
  • 6
  • 17