I made the method shown below that works when I debug, but don't when
I run...
public void downloadFile(File localFile, URL urlTarget) throws
IOException
{
InputStream is = urlTarget.openConnection().getInputStream();
FileOutputStream os = new FileOutputStream(localFile);
int i=0;
int offset= 0;
while(is.available()>0){
byte[] b = new byte[is.available()];
offset += is.read(b,offset,is.available());
os.write(b);
}
I think that when I run the method the connection did not have
enougth time to make any data avaliable making is.available() == 0
even when there is a entire file to come...
how can I work around this?