More debug to data downloader - it suddenly started to misbehave after I've increased buffer size

This commit is contained in:
pelya
2010-05-20 18:37:42 +03:00
parent 8b5b153c8b
commit 16efa9e976
2 changed files with 13 additions and 2 deletions

View File

@@ -233,16 +233,19 @@ class DataDownloader extends Thread
Status.setText( percent + "writing file " + path );
try {
int len;
while ((len = zip.read(buf)) > 0)
int len = zip.read(buf);
while (len > 0)
{
out.write(buf, 0, len);
len = zip.read(buf);
percent = "";
if( totalLen > 0 )
percent = String.valueOf(stream.getBytesRead() * 100 / totalLen) + "%: ";
Status.setText( percent + "writing file " + path );
}
out.flush();
out.close();
} catch( java.io.IOException e ) {
Status.setText( "Error writing file " + path );
return;
@@ -256,6 +259,7 @@ class DataDownloader extends Thread
out = new FileOutputStream( path );
out.write(0);
out.flush();
out.close();
} catch( FileNotFoundException e ) {
} catch( SecurityException e ) {
} catch( java.io.IOException e ) {
@@ -272,6 +276,11 @@ class DataDownloader extends Thread
Status.setText( "Finished" );
DownloadComplete = true;
try {
stream.close();
} catch( java.io.IOException e ) {
};
initParent();
};