Vijay,

It's wrong to use a DataInputStream this way. DataInputStream is for serialized Java objects! A typical beginner's mistake I should put in my list of anti-patterns: http://www.odi.ch/prog/design/newbies.php

The correct way to copy a byte stream to disk is:

InputStream in = new BufferedInputStream(responseBodyStream);
FileOutputStream fos = new FileOutputStream("rwservlet.pdf");
byte[] buffer = new byte[4098];
int len = 0;
while ((len = in.read(buffer) > 0) {
    fos.write(buffer, 0, len);
}

Cheers

Ortwin

Vijay Gomatam wrote:
DataInputStream data = new DataInputStream(new
BufferedInputStream(responseBodyStream));
> FileOutputStream fos = new FileOutputStream("rwservlet.pdf");
>
> *while* ((c =data.read(b)) != -1){
>
> *byte*[] inter=*new* *byte*[c];
>
> *for*(*int* i=0;i<c;i++)  inter[i]=b[i];
>
> fos.write(inter);
>
> }


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to