开发者

Android ftp bytes transferred

开发者 https://www.devze.com 2023-03-13 03:36 出处:网络
I\'m using Apache Commons ftp library on Android. How it is possible to know the amount of data transferred during upload or download of a file and show it on a pr开发者_如何学运维ogress dialog?Maybe

I'm using Apache Commons ftp library on Android. How it is possible to know the amount of data transferred during upload or download of a file and show it on a pr开发者_如何学运维ogress dialog?


Maybe this code can point you in the right direction:

try {
  InputStream stO = new BufferedInputStream(ftp.retrieveFileStream("foo.bar"),
                ftp.getBufferSize());
  OutputStream stD = new FileOutputStream("bar.foo");

  org.apache.commons.net.io.Util.copyStream(stO, stD, ftp.getBufferSize(),
                CopyStreamEvent.UNKNOWN_STREAM_SIZE,
                new CopyStreamAdapter() {
                    public void bytesTransferred(long totalBytesTransferred,
                            int bytesTransferred,
                            long streamSize) {
                            // Your progress Control code here
                    }
        });
        ftp.completePendingCommand();
} catch (Exception e) { ... }
0

精彩评论

暂无评论...
验证码 换一张
取 消