CXF与Spring整合下载文件一

本文介绍了一个使用 Spring 的 XML 配置方式来创建客户端应用的例子。该客户端通过 Spring 容器获取一个 XML 服务器接口实例,并从服务器获取指定用户的数据,然后将数据保存为本地文件。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

文件文件文件文件
请看附件


Main方法类
/**
*
*/
package personal.zhangqian.demo.server;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;

import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
* @author zhangqian
*
*/
public class Client {

/**
* @param args
* @throws IOException
*/
public static void main(String[] args) throws IOException {
ClassPathXmlApplicationContext application = new ClassPathXmlApplicationContext(
"classpath:applicationContext-*.xml");
IXmlServer server = (IXmlServer) application.getBean("xmlServer");
ExportFile file = server.getXml("zhangsan");
InputStream io = file.getFileData().getInputStream();
File out = new File("d:\\test.xml");
out.createNewFile();
FileOutputStream fos = new FileOutputStream(out);
byte[] b = new byte[1024];
int c;
while ((c = io.read(b)) != -1) {
fos.write(b, 0, c);
}
fos.close();
io.close();
}

}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值