【发布时间】:2011-10-01 10:46:41
【问题描述】:
我正在使用此代码下载文件,我想知道是否可以暂停下载然后稍后恢复,如果可以,如何?:
URL url = new URL(URL);
URLConnection conexion = url.openConnection();
conexion.connect();
int lenghtOfFile = conexion.getContentLength();
lenghtOfFile /= 100;
InputStream input = new BufferedInputStream(url.openStream());
OutputStream output = new FileOutputStream(Path + FileName);
byte data[] = new byte[1024];
long total = 0;
int count = 0;
while ((count = input.read(data)) != -1) {
output.write(data, 0, count);
total += count;
}
output.flush();
output.close();
input.close();
【问题讨论】: