Results 1 to 6 of 6
  1. #1
    vernianCoder is offline Member
    Join Date
    Dec 2011
    Posts
    2
    Rep Power
    0

    Default read file in its entirety

    hi,

    im trying to write a HEX editor in java. I can read the contents of a file fine, but I really need to read every single piece of the file, including headers etc..

    would appreciate any help

    thanks!

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,306
    Rep Power
    25

    Default Re: read file in its entirety

    I can read the contents of a file fine
    Where are the parts of the file that you don't read? If you read all of the file's contents, where is there more to be read?
    Are you referring to other info that is in the directory that describes the file like its date last modified?

  3. #3
    vernianCoder is offline Member
    Join Date
    Dec 2011
    Posts
    2
    Rep Power
    0

    Default Re: read file in its entirety

    if I have a text file that contains just the string "abc123" and I read it using inputStreamReader for instance, and then write it to the screen, it will display just "abc123". no other part of the file is read, no headers etc..

  4. #4
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,306
    Rep Power
    25

    Default Re: read file in its entirety

    What is a "header" for a text file?
    If the file contains only "abc123" and possible lineend char(s) what other part of the file is there to read?

    What OS are you on? Does it save meta or OS data as well as the file's contents with a file on disk?

  5. #5
    2by4 is offline Banned
    Join Date
    Dec 2011
    Posts
    143
    Rep Power
    0

    Default Re: read file in its entirety

    Do you mean the BOM for example, that you can see in a hex editor?

  6. #6
    2by4 is offline Banned
    Join Date
    Dec 2011
    Posts
    143
    Rep Power
    0

    Default Re: read file in its entirety

    Looking at the spec for InputStreamReader it has to do translation from byte to char, so it has to read the BOM before it can start translating, for example.

    Have you tried plain old FileInputStream? A hex editor shouldn't be assuming the data is characters.

Similar Threads

  1. Replies: 1
    Last Post: 08-05-2011, 09:21 PM
  2. Replies: 2
    Last Post: 05-11-2009, 10:07 AM
  3. Replies: 0
    Last Post: 02-11-2009, 09:53 AM
  4. Replies: 5
    Last Post: 02-05-2009, 10:28 AM
  5. How to read a text file from a Java Archive File
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 02-08-2008, 09:13 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
  •