Jimmy Zhang said:
Hi,
I am looking for ways to get access to InputStream's underlying byte
buffer structure. I heard that I have to
look into the java.nio class for that. So far haven't found it. Any help is
greatly appreciated.
What type of input stream? Input Stream is an abstract Class and it doesn't
have an underlying byte buffer. It just defines a few methods for reading
bytes into byte arrays. BufferedInputStream has a buffer which in fact you
can access if you extend the class since the buffer has protected access.
However, why do you want to access the buffer?
Unless you are very careful, if you do anything with the buffer you have a
good chance of stuffing up the working of the class. And if you think that
you might speed up the reading of the data (which you probably won't) then
simply do a read providing a large byte array (larger than the default size
of 2048). In that case the data is read directly into that buffer instead of
the internal buffer anyway.
In any case why not just examine the code in the java classes. It is
provided in the SDK.
Cheers
Andrew
--
********************************************************
Andrew Hobbs PhD
MetaSense Pty Ltd -
www.metasense.com.au
12 Ashover Grove
Carine W.A.
Australia 6020
61 8 9246 2026
metasens AntiSpam @iinet dot net dot au
*********************************************************