2011-06-13 27 views

回答

1

也許這個代碼可以爲您指出正確的方向:

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) { ... }