Results 1 to 3 of 3
  1. #1
    yuvalzi is offline Member
    Join Date
    Jun 2011
    Posts
    2
    Rep Power
    0

    Default Compare FileReader and FileInputStream

    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

  2. #2
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,563
    Rep Power
    25

    Default

    Can you post the code?
    Hex 0x01 is not the same as the char '1' or the String "1".

    Can you read the file in a hex editor and post its contents in hex.

  3. #3
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,091
    Rep Power
    20

    Default

    And can you pick one of your two posts (that I've spotted) and close the other one?
    Because double posting is a bit rude...and impatient.

    See my post on the other thread you started...

Similar Threads

  1. problem regarding FileReader
    By mukeshpaliwal in forum New To Java
    Replies: 7
    Last Post: 10-01-2010, 03:15 PM
  2. Replies: 5
    Last Post: 02-02-2010, 09:06 AM
  3. FileReader help
    By emp in forum New To Java
    Replies: 1
    Last Post: 07-28-2009, 04:41 AM
  4. add FileReader to GUI
    By VinTiger in forum New To Java
    Replies: 8
    Last Post: 05-11-2009, 12:23 AM
  5. Help with filereader in java
    By zoe in forum Advanced Java
    Replies: 2
    Last Post: 07-26-2007, 09:55 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •