当我在Android中将 file-A 复制到 folder-B 时,我想使用ProgressDialog(ProgressDialog.STYLE_HORIZONTAL)
。
示例1:
String mStart = "/sdcard/aaaa/";
FileInputStream fis = new FileInputStream(mStart);
FileOutputStream fos = new FileOutputStream(path);
FileChannel fin = fis.getChannel();
FileChannel fout = fos.getChannel();
File f = new File(mStart);
fin.transferTo(0, f.length(), fout);
示例2:
byte[] buffer = new byte[1024];
while ((readcount = bin.read(buffer, 0, 1024)) != -1) {
bout.write(buffer, 0, readcount);
publishProgress(readcount);
}
如果我使用第二个例子,我可以使用ProgressDialog()
,但在第一个例子中,我不能。
如何在使用ProgressDialog
方法时更新transferTo()
?