Quanyu,
It actually depends on what you want to do with the file. If you can read it bit
by bit and not have it in memory all the time, a BufferedInputStream on top of
an InputStream will probably help performance. If you need random access to the
file, use the RandomAccessFile class.
Otherwise, you will have memory problems unless you have HUGE amounts of RAM in
your machine
Hope this helps,
-Mario.
Quanyu Zhu wrote:
> Hi:
> I just have one mission to read a huge file(more than 500M) using
> java. Is there anyone having such kind of experiences on that?
> My system is Java1.1.7a and running on Windows95/NT or Linux with
> X-windows. And my runtime configuration is setting up 100M to 500M
> memory size ,but my real Hdisk just left 500M free space.
> In my program, Firstly, I used the DataInputStream to read one byte by
> byte, but it seems too slow.
> Then I used the ReadFully to read the whole file into one large btye
> array. The performance imporved a lot.
> But what I will deal with is the huge file, more than 500M, how can I
> allocate this huge array?
> Does anyone have such experience on that?
> Is there any way to free the array I allocated like in C/C++? It seems
> the only way to free the unused memory is done by garbage collection
> thread, do I have any way to destory the memory which I allocated just
> using one method ???
> Any hint will be appreciated !!!
>
> Best Regard
> Kevin Zhu
>
>
> ______________________________________________________
> Get Your Private, Free Email at http://www.hotmail.com