I'm writing a program to download binary files, and my InputStream is blocking... forever.

I've created an InputStream and OutputStream, and a byte[], and I'm using the byte[] to read a certain number of bytes at a time and write them to the OutputStream inside a loop.
Every time I run the program it runs through the loop anywhere between 100 and a few thousand times (nowhere near enough to get through a single file) and then blocks.

The offending code follows:

int length;
while((length = inputStream.read(b)) != -1)
outStream.write(b, 0, length);

I've debugged it and I know for a fact it is just waiting inside the condition cause of the while loop. I've let it sit for several minutes and it never unblocks. I know there's data there because if I type the URL of the file into a browser, the file loads just fine.

How do I jump start it again?