package per.hwf.netftp;
import java.io.BufferedInputStream;
import java.io.InputStream;
import java.io.OutputStream;
import org.apache.commons.net.ftp.FTPClient;
import org.apache.commons.net.io.CopyStreamAdapter;
import org.apache.commons.net.io.CopyStreamEvent;
import org.apache.commons.net.io.Util;
public class FtpTest {
public void test() {
try {
String fileName = "";
OutputStream fout = null;
org.apache.commons.net.ftp.FTPClient ftps = null;
InputStream stO = new BufferedInputStream(ftps
.retrieveFileStream(fileName), ftps.getBufferSize());
Util.copyStream(stO, fout, ftps.getBufferSize(),
CopyStreamEvent.UNKNOWN_STREAM_SIZE,
new MyCopyStreamAdapter());
} catch (Exception e) {
e.printStackTrace();
}
}
public class MyCopyStreamAdapter extends CopyStreamAdapter
{
public void bytesTransferred(
long totalBytesTransferred,
int bytesTransferred, long streamSize) {
// changeSupport.firePropertyChange(FTPPERCENT, null,
// totalBytesTransferred*100/length);
}
}
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
}
}
CopyStreamAdapator
最新推荐文章于 2021-09-15 18:55:43 发布