-1

I have a RandomAccessFile reading from a file that contains ISO-8859-1 characters (åäö). But when use seek() and readLine() on the file I get aagÃ¥rd instead of aagård. Any clue why this is?

tomoswizzard
  • 65
  • 1
  • 2
  • 6

1 Answers1

0

ReadLine doesn't support UTF format as in javadoc: https://docs.oracle.com/javase/7/docs/api/java/io/RandomAccessFile.html#readLine()

Reads the next line of text from this file. This method successively reads bytes from the file, starting at the current file pointer, until it reaches a line terminator or the end of the file. Each byte is converted into a character by taking the byte's value for the lower eight bits of the character and setting the high eight bits of the character to zero. This method does not, therefore, support the full Unicode character set.

Try ReadUTF() instead:

Reads in a string from this file. The string has been encoded using a modified UTF-8 format.

JFPicard
  • 5,029
  • 3
  • 19
  • 43