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

    Default Compare FileReader and FileInputStream


    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 one byte after another and print the contents to the console, i get the following values:

    But if i run it with i get the following values:

    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
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Rep Power


    What code do you use for each?
    If you are simply comparing the output of a read() call on the stream compared to the reader then they will be different.
    The reader reads characters. The stream reads bytes.

Similar Threads

  1. Compare FileReader and FileInputStream
    By yuvalzi in forum New To Java
    Replies: 2
    Last Post: 06-29-2011, 04:00 PM
  2. FileReader errors
    By iochinome in forum Java Applets
    Replies: 1
    Last Post: 12-04-2010, 07:12 AM
  3. Replies: 5
    Last Post: 02-02-2010, 10:06 AM
  4. FileReader help
    By emp in forum New To Java
    Replies: 1
    Last Post: 07-28-2009, 05:41 AM
  5. add FileReader to GUI
    By VinTiger in forum New To Java
    Replies: 8
    Last Post: 05-11-2009, 01:23 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