Re: Loading null-terminated strings from file

Discussion in 'Java' started by Roedy Green, Jul 9, 2003.

  1. Roedy Green

    Roedy Green Guest

    On Wed, 09 Jul 2003 15:36:14 GMT, "<insert my name here>"
    <> wrote or quoted :

    >What's the easiest way to load a series of strings from a file where
    >each string is simply a null-terminated string of bytes (non-unicode)
    >and there are no special (ie: CR/LF) characters involved?


    read them as raw bytes one at a time from a BufferedInputStream in a
    loop. Then convert byte arrays you create to strings with an
    encoding.

    See http://mindprod.com/fileio.html for sample code to read the bytes
    and http://mindprod.com/converter.html for how to convert the byte
    array to a String.

    --
    Canadian Mind Products, Roedy Green.
    Coaching, problem solving, economical contract programming.
    See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.
     
    Roedy Green, Jul 9, 2003
    #1
    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. Barry

    strncpy() and null terminated strings

    Barry, Apr 8, 2004, in forum: C Programming
    Replies:
    4
    Views:
    1,172
    Malcolm
    Apr 8, 2004
  2. Roy Smith
    Replies:
    2
    Views:
    1,963
    Peter Otten
    Mar 6, 2004
  3. Matt Helm
    Replies:
    5
    Views:
    1,620
    Matt Helm
    Feb 6, 2006
  4. Grey Alien

    Working with NON-NULL terminated strings

    Grey Alien, Jul 14, 2007, in forum: C Programming
    Replies:
    4
    Views:
    616
    santosh
    Jul 18, 2007
  5. ssylee
    Replies:
    4
    Views:
    517
    CBFalconer
    Aug 12, 2008
Loading...

Share This Page