Reading a file using BufferedStream and avoiding String manipulation

T

tourist.tam

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
 
M

Marc Gravell

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.ReadAllText(), strings should work OK too. AFAIK qqthey aren't
interned when used in this way, so should get collected.

Any help?

Marc
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top