There is a requirement to create a file with all utf-8 characters using Java or create all utf8 characters as string at runtime. I have tried to create the string by using below code.
char data[] = new char[65536];
for (int index = 0; index < 65536; index++) {
data[index] = (char) index;
}
But when I try to print this character as string on console, I see there are many '?' symbols. I am not sure if this is the right way to generate the utf8 character set. I read that utf character can be 1-4 bytes range. But java char is 2 bytes. I think there should be something that I am doing wrong in this case. I went through many links, but could not find the appropriate answer. Can someone help regarding this.