Reading a file using BufferedStream and avoiding String manipulation

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • tourist.tam@googlemail.com

    #1

    Reading a file using BufferedStream and avoiding String manipulation

    Hi,

    I am trying to read a file using a BufferedStream and avoiding at
    maximum the use of string manipulation. I need now some help
    understanding on how to use byte array to hold the data and manipulate
    those. I do understand that I will have to pass any of the array
    created into strings at the end of the process. But I am missing the
    intermediate steps. And being just introduced to JAVA, my
    understanding of processing large plain text file stops on how to
    manipulate strings (which seems to have a memory issue) ...

    So any help is welcome.

    Tam

  • Marc Gravell

    #2
    Re: Reading a file using BufferedStream and avoiding String manipulation

    If the data is text, your best bet is to use a TextReader to parse the
    file (rather than doing it yourself via an encoding); the StreamReader
    that you get from File.OpenText() should do the job. The Read() method
    of this reads characters into a buffer.

    However, for most purposes, as long as you aren't using
    File.ReadAllTex t(), strings should work OK too. AFAIK qqthey aren't
    interned when used in this way, so should get collected.

    Any help?

    Marc

    Comment

    Working...