开发者

Android ftp bytes transferred

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜