Originariamente inviato da sicenti
probabilmente c'è un problema con il file che ottieni, prova a postare il codice del run()
Allora, questo e' il run:
codice:
public void run()
{
RandomAccessFile file = null;
InputStream stream = null;
try
{
// Open connection to URL.
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
// Specify what portion of file to download.
connection.setRequestProperty("Range", "bytes=" + downloaded + "-");
// Connect to server.
connection.connect();
// Make sure response code is in the 200 range.
if (connection.getResponseCode() / 100 != 2)
{
error();
}
// Check for valid content length.
int contentLength = connection.getContentLength();
if (contentLength < 1)
{
error();
}
// Set the size for this download if it hasn't been already set.
if (size == -1)
{
size = contentLength;
stateChanged();
}
// Open file and seek to the end of it.
file = new RandomAccessFile(getFileName(url), "rw");
file.seek(downloaded);
stream = connection.getInputStream();
while (status == DOWNLOADING)
{
/* Size buffer according to how much of the file is left to download. */
byte buffer[];
if (size - downloaded > MAX_BUFFER_SIZE)
{
buffer = new byte[MAX_BUFFER_SIZE];
}
else
{
buffer = new byte[size - downloaded];
}
// Read from server into buffer.
int read = stream.read(buffer);
if (read == -1)
{
break;
}
// Write buffer to file.
file.write(buffer, 0, read);
downloaded += read;
stateChanged();
}
/* Change status to complete if this point was
reached because downloading has finished. */
if (status == DOWNLOADING)
{
status = COMPLETE;
stateChanged();
}
}
catch (Exception e)
{
error();
}
finally
{
// Close file.
if (file != null)
{
try
{
file.close();
}
catch (Exception e)
{
}
}
// Close connection to server.
if (stream != null)
{
try
{
stream.close();
}
catch (Exception e)
{
}
}
}
}
Viene chiamato sia quando il download inizia da zero che quando riparte (per questo salvo il punto in cui sono arrivato su file xml).
Questo invece e' il costruttore usato quando carico i dati dal file xml (per sapere dove sono arrivato):
codice:
public Download(URL url, int downloaded, int size)
{
this.url = url;
this.downloaded = downloaded;
this.size = size;
status = DOWNLOADING;
// Begin the download.
download(); // crea e fa partire il thread per il download
}
Non riesco proprio a capire cosa c'e' che non va 
Intanto grazie