Ciao; scusami am se non trova il file non ti genera una IOException io fossi in te farei:
Codice PHP:
public boolean download(String nomeFile){
boolean trovato = false;
InputStream inStream=null;
URL url;
try {
url = new URL(urlPath + nomeFile);
while (!trovato) {
inStream = url.openStream();
if (inStream.available() > 0)
trovato = true;
else
trovato = false;
}
}
catch (MalformedURLException e) {
return false;
}
catch (IOException ie) {
return false;
}
try {
FileOutputStream outStream = new FileOutputStream(percorsoCartine + nomeFile);
int numByte;
byte buffer[] = new byte[2048];
while ((numByte = inStream.read(buffer,0,buffer.length))>=0) {
outStream.write(buffer,0,numByte);
}
outStream.close();
inStream.close();
}
catch (IOException e) {
return false;
}
return true;
}