I'm using Eclipse with compiler 1.5 to build a program, which is to download some jar files from an URL. It's working in my own PC, with JRE 1.6.0_01. But it's not working in another PC, with JRE 1.5.0_11. On the PC with JRE 1.5, it only downloaded/created empty jar files.
Here is the code for downloading:
For the PC that is JRE 1.5, the code while (ins.available() != 0) did not get executed at all.
Is there anything wrong with this code?
I think you have a misunderstanding of the available() method. The available() method returns the number of bytes which can be read without blocking -- it doesn't return the number of bytes til the end of file. So, your loop will copy only what is buffered -- which can be different from system to system, depending on how much read-ahead the OS does.
[EDIT: Wow. I didn't know that there was a FAQ for this... ]