关于旗正规则引擎规则中的上传和下载问题

文件的上传下载都是数据流的输入输出,大致流程都是一样的。
一、文件打包下载
1.文件写入压缩包
string mainPath="D:\upload\"; 下载路径

string tmpfileName=jar.zip; 压缩文件名
string lsml=System.getProperty("java.io.tmpdir")+"\"; 临时目录
string zipPath=lsml+tmpfileName; 压缩文件下载路径
byte buffer[]=new byte[1024];

file tmpFile=new file(zipPath)
if(!tmpFile.exists()){
tmpFile.creatNewfile();
} 创建压缩文件

FileOutputStream fos=new FileOutputStream(tmpFile);
ZipOutputStream zos=new ZipOutputStream(fos);

File[] file=new File(mainPath+需要下载文件的文件名);

for(i=0;i<file.length;i++){
FileInputStream fis=new FileInputStream(file[i]); 需要下载的文件读入输入流
zos.putNextEntry(new ZipEntry(file[i].getName())); 文件写入zip中
zos.setEncoding("GBK");
int x=0;
while((x=fis.read(buffer))!=-1){
zos.write(buff,0,x);
}
zos.closeEntry();
fis.close();
}
zos.close();
fos.close();

2.压缩包下载
File file=new File(zipPath);
if(file.exists()){
InputStream ins=new InputStream(zipPah);
BuffInputStream bis=new BuffInputStream(ins);
OutputStream outs=response.OutputStream();
BuffOutputStream bos=new BuffOutputStream(outs);
int y=0;
byte[] buffer = new byte[1024];
while((y=bis.read(buffer)!=-1){
bos.write(buffer,0,y);
}
bos.flush();
ins.close();
bis.close();
outs.close();
bos.close();
}
将以上流程按照设计的需求,写入到相应规则就可以了。
二、文件上传
对于文件上传,flagleader规则引擎中对于的jsp页面中有上传文件的功能,默认会将文件储存到C:\VisualRules\Tomcat\temp目录下
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值