不显示删除回复显示所有回复显示星级回复显示得分回复 在C/S架构中,用java实现下载Excel模板的功能

aCfeng 2011-11-18 06:22:42
遇到一个棘手的问题,在C/S架构中,用java实现下载Excel模板的功能,在网络查的都是jsp的方式,没有找到C/S架构的,我是用swing做的,把Excel放到了一个项目文件夹中,用户下载的时候直接下载到用户选择的路径中,该怎么实现 ,我用这种方式实现的,但是有问题
protected void loadTemplateAction_actionPerformed(ActionEvent e) throws Exception {
JFileChooser chooser = new JFileChooser();
//要想添加默认的文件名,需将setSelectedFile()这个方法放到打开对话框之前
String defaultFileName = "customers.csv";
chooser.setSelectedFile(new File(defaultFileName));

chooser.showSaveDialog(this);

FileInputStream fis = null;
FileOutputStream fos = null;
String sourcefileUrl = "ini/template1/customers.csv";
String outUrl = chooser.getCurrentDirectory().getPath();
File sourceFile = new File(sourcefileUrl);

File targetFile = new File(outUrl);

fis = new FileInputStream(sourceFile);

byte[] b = new byte[(int) sourceFile.length()];
int len = fis.read(b);
while(len>0){
fos = new FileOutputStream(targetFile);
System.out.println("len:"+len);
System.out.println("os:"+fos);
fos.write(b, 0, len);
fos.flush();
}

fis.close();


contentFileNameText.setText("模板下载成功...");
}

请大家帮帮忙,谢谢了
...全文
40 回复 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

662

社区成员

发帖
与我相关
我的任务
社区描述
提出问题
其他 技术论坛(原bbs)
社区管理员
  • community_281
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧