Thanks Roland.

But your suggestion doesn't seem to be working. Invoking 
Entity.getContentLength() returns, correctly, 80MB of data to be read, but when 
I read from the InputStream, I only get a few kB.

Also, if I use curl I do get 80MB, so the data should be there.

The code I'm using is below. If you could point out errors, or suggest anything 
else to try, I'd appreciate it.

Nadeem

    public static void writeToFile(HttpResponse resp, String pathToFile) {
        HttpEntity entity = resp.getEntity();
        InputStream instream;
        try {
            instream = entity.getContent();
            if (instream == null) {
                System.out.println("instream == null");
            }
            System.out.println("entity content length: " + 
entity.getContentLength());

            long bytesRead = 0;
            FileOutputStream output = new FileOutputStream(new 
File(pathToFile));
            
            try {
                byte[] tmp = new byte[1024];
                int l;
                while((l = instream.read(tmp)) != -1) {
                    bytesRead += l;
                    output.write(tmp, 0, l);
                }
                System.out.println("bytes read: " + bytesRead);
            } finally {
                instream.close();
            }        
        } catch (IllegalStateException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }





       
____________________________________________________________________________________
Be a better Globetrotter. Get better travel answers from someone who knows. 
Yahoo! Answers - Check it out.
http://answers.yahoo.com/dir/?link=list&sid=396545469

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

Reply via email to