How to make my download class faster
Hi,
Currently I'm working on a small downloadmanager for personal use, it's working fine so far, except that it downloads rather slowly. My downloadmanager averages on about 170~ kb/s when downloading file, but when I download the same file regularly it downloads at 640~ kb/s.
My download function:
Code:
public void Download() {
try {
HttpURLConnection huc = this.Gethuc(this.FileLink + "?directstart=1");
InputStream is = huc.getInputStream();
FileOutputStream fos = new FileOutputStream(this.GetLocalFile());
this.SetFileSize(huc.getContentLength());
int SingleByte;
while ((SingleByte=is.read()) != -1) {
fos.write(SingleByte);
}
is.close();
fos.close();
} catch (MalformedURLException e) {
System.err.println(e.toString());
} catch (IOException e) {
System.err.println(e.toString());
}
}
Does anyone know a way to make it faster?
Thanks in advance.