3 Replies Latest reply: Jun 29, 2011 7:30 AM by rukbat RSS

    Compare FileReader and FileInputStream

    Yuval Zilberstein
      hi,

      I have a file with the following char, saved as utf-8:
      "*Č*"

      The character is the unicode hex value "*010C*" (Latin Extended-A).
      As much as i understand it is saved as binary values: 00000001 00001100
      I am running on windows XP and the default character-set of the JVM is the codebase "*windows-1252*".

      When reading the values with java.io.FileInputStream one byte after another and print the contents to the console, i get the following values:
      *196*
      *140*

      But if i run it with java.io.FileReader i get the following values:
      *196*
      *338*
      Why is there such a difference?

      Why doesnt it print:
      *1 -- equivalent to first 2 hex digits - (01)*
      *12 -- equivalent to last 2 hex digits - (0C)*

      Thanks Yuval