dcsimg
BufferedInputStream returns corrupt data
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Zeyad_Ali
Posted On:   Saturday, May 25, 2002 12:11 PM

I am trying to read a file on a remote server using FTP. After sending the request I use BufferedInputStream to read the incoming data in a byte array. I always get corrupt data. Even that I know the file size before requesting it. BufferedInputStream in = new BufferedInputStream(data.getInputStream()), fileSize); byte[] dataBytes= new byte[fileSize]; in.read(dataBytes); If I use dataInputStream.readFully(dataBytes), it works but very slow. I also do not want to read the file in chunks. I think that the byte[] is read before fetching the data. How can I still use BufferedInputStream without getting corrupt data?    More>>

I am trying to read a file on a remote server using FTP.
After sending the request I use BufferedInputStream to read the incoming data in a byte array. I always get corrupt data. Even that I know the file size before requesting it.

BufferedInputStream in =
new BufferedInputStream(data.getInputStream()), fileSize);


byte[] dataBytes= new byte[fileSize];


in.read(dataBytes);


If I use dataInputStream.readFully(dataBytes), it works but very slow.
I also do not want to read the file in chunks.
I think that the byte[] is read before fetching the data. How can I still use BufferedInputStream without getting corrupt data?

   <<Less
About | Sitemap | Contact