<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ftp="http://servicemix.apache.org/ftp/1.0" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://servicemix.apache.org/ftp/1.0 http://servicemix.apache.org/schema/ftp/servicemix-ftp-1.0.xsd"> <ftp:remoteFileProducer endpoint="ftp://username:password@localhost:21/targetFolder?charset=utf-8&amp;passiveMode=true" id="producer1" /> <ftp:remoteFileProducer endpoint="ftp://username:password@localhost:21/anotherFolder?charset=utf-8&amp;passiveMode=true" id="producer2" /> </beans> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ftp="http://servicemix.apache.org/ftp/1.0" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://servicemix.apache.org/ftp/1.0 http://servicemix.apache.org/schema/ftp/servicemix-ftp-1.0.xsd"> <bean id="ftpServerConfig" class="org.apache.commons.net.ftp.FTPClientConfig"> <property name="serverAddress" value="${ftp.server}" /> <property name="username" value="${ftp.username}" /> <property name="password" value="${ftp.password}" /> </bean> <ftp:remoteFileProducer id="producer1" endpoint="ftp://${ftp.server}/targetFolder?charset=utf-8&amp;passiveMode=true" ftpClientConfig="#ftpServerConfig" /> </beans> public class FTPDownloadClient { public static void main(String[] args) throws Exception { ServiceMixServer server = new ServiceMixServer(); RemoteFileEndpoint endpoint = server.getEndpoint("ftp://username:password@localhost:21/sourceFolder?charset=utf-8&passiveMode=true"); Exchange exchange = endpoint.createExchange(ExchangePattern.InOnly); exchange.getIn().setHeader(Exchange.FILE_NAME, "file.txt"); endpoint.send(exchange); server.stop(); } }


上一篇:
下一篇:
切换中文