I am trying to read a file which contains some japanese characters.
RandomAccessFile file = new RandomAccessFile("japanese.txt", "r");
String line;
while ((line = file.readLine()) != null) {
System.out.println(line);
}
Its returning some garbled characters instead of japanese. But when I am converting the encoding, it printing it properly.
line = new String(line.getBytes("ISO-8859-1"), "UTF-8");
What does this mean? Is the text file in ISO-8859-1 encoding?
$ file -i japanese.txt
returns following:
japanese.txt: text/plain; charset=utf-8
Please explain which it explicitely requires the file to convert from Latin 1 to UTF-8?