NullPointerException GZIPOutputStream

Does anyone know, why I get a NullPointerException in the line

while (length = in.read(BinaryBody)) != -1)?

byte[] BinaryBody =newbyte[8192];

InputStream in = method.getResponseBodyAsStream();

GZIPOutputStream gzipOut =new GZIPOutputStream(client.getOutputStream());

int length;

while ((length = in.read(BinaryBody)) != -1)

{

gzipOut.write(BinaryBody, 0, length);

gzipOut.flush();

}

gzipOut.close();

[725 byte] By [Johannesa] at [2007-11-15]
# 1

Oh, I think actually it has to be

byte[] BinaryBody = new byte[8192];

InputStream in = method.getResponseBodyAsStream();

GZIPInputStream gzipIn = new GZIPInputStream(in);

GZIPOutputStream gzipOut = new GZIPOutputStream(client.getOutputStream());

int length;

while ((length = gzipIn.read(BinaryBody)) != -1)

{

gzipOut.write(BinaryBody, 0, length);

gzipOut.flush();

}

gzipOut.close();

gzipIn.close();

I'm writing a Proxyserver and just wanted to forward gzipped Data to the client, but my UA/Browser is getting a timeout after a few minutes, I'm not sure what's wrong :-/

Hrm, I'm getting a NullPointerException in the following line: GZIPInputStream gzipIn = new GZIPInputStream(in);

Message was edited by:

Johannes

Johannesa at 2007-7-12 > top of java,Core,Core APIs...
# 2
If you're writing a proxy server why do anything to the data? Just read and write the bytes.
ejpa at 2007-7-12 > top of java,Core,Core APIs...