`
Jony.Hwong
  • 浏览: 115221 次
  • 来自: ...
社区版块
存档分类
最新评论

CopyStreamAdapator

阅读更多
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

	}

}

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics