search & replace in binary file

Discussion in 'Java' started by Ike, Nov 27, 2006.

  1. Ike

    Ike Guest

    I have a binary file which I must rewrite out to the local disk. In the
    process of doing that, there are some 30 character strings I must search and
    replace with a different corresponding string to each of those 30 character
    strings. Each of these strings is between 10 and 500 bytes long.

    Can someone please tell me what htey think the most efficient and effective
    way to do this might be? TIA, Ike
     
    Ike, Nov 27, 2006
    #1
    1. Advertising

  2. Ike

    Tony Dahlman Guest

    Ike at a hotmail address wrote:
    > I have a binary file which I must rewrite out to the local disk. In the
    > process of doing that, there are some 30 character strings I must search

    and
    > replace with a different corresponding string to each of those 30

    character
    > strings. Each of these strings is between 10 and 500 bytes long.


    > Can someone please tell me what htey think the most efficient and

    effective
    > way to do this might be? TIA, Ike


    Hey Ike! I guess all files are binary, or hex or octal, or something,
    aren't
    they? Worse yet, the characters could be any language -- did you think of
    that?

    Anyway, you might want to read in at least 500 bytes at a time, into a
    buffer
    of at least 1,000 bytes. Then you search and replace as needed. The only
    problem I see is if the "local disk" is full and you can't write your
    results until you've deleted the previously read portions of the file.

    By the way, how are you doing on this? Do you have any code that you
    could
    share with the folks here? Knowing whether your problem is I/O, i18n, or
    proprietary/encoded data, or something else might help readers of the
    newsgroup to help you.
     
    Tony Dahlman, Nov 30, 2006
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Andy
    Replies:
    1
    Views:
    367
    Jack Klein
    Nov 25, 2003
  2. Timmy
    Replies:
    5
    Views:
    484
  3. Replies:
    9
    Views:
    462
    Keith Thompson
    Jul 3, 2009
  4. Bogdan

    Binary tree search vs Binary search

    Bogdan, Oct 18, 2010, in forum: C Programming
    Replies:
    22
    Views:
    3,139
    Michael Angelo Ravera
    Oct 21, 2010
  5. Rafal Konopka

    search and replace in a binary file

    Rafal Konopka, Jul 22, 2006, in forum: Perl Misc
    Replies:
    6
    Views:
    329
    Martijn Lievaart
    Jul 23, 2006
Loading...

Share This Page