package com.wabacusdemo.util;
import java.io.BufferedInputStream;
import java.io.ByteArrayOutputStream;
import java.io.FileInputStream;
import org.directwebremoting.io.FileTransfer;
public class DownLoadFile {
public FileTransfer downloadPdfFile(String contents) throws Exception {
if (contents == null || contents.length() == 0) {
contents = "[BLANK]";
}
BufferedInputStream in = new BufferedInputStream(new FileInputStream("c:/Aix 脆弱性库.xls"));
ByteArrayOutputStream out = new ByteArrayOutputStream();
byte[] temp = new byte[1024];
int size = 0;
while ((size = in.read(temp)) != -1)
{
out.write(temp, 0, size);
}
String filename ="测试.doc";
return new FileTransfer(new String( filename.getBytes("GBK"),"iso8859-1" ), "application/doc", out.toByteArray());
}
}
function downloadPdfFile() {
// var pdftext = dwr.util.getValue('pdftext');
DownLoadFile.downloadPdfFile("ddd", function(data) {
dwr.engine.openInDownload(data);
});
}
分享到:
相关推荐
本文将详细介绍如何使用DWR 3.0来实现文件的下载。 首先,我们需要了解DWR的基本工作原理。DWR通过在服务器端创建一个代理类,使得JavaScript可以直接调用服务器端的方法,而无需通过传统的HTTP请求。这种机制使得...
描述中提到的 "dwr的简单例子" 指的是Direct Web Remoting (DWR) 技术,它是一种允许JavaScript在浏览器端与Java在服务器端进行交互的技术,从而实现动态Web应用程序的功能。 现在我们逐个分析压缩包内的文件名: ...
2017年存储技术变革与发展的趋势.pdf
毕业论文-qing游戏风格 商业版(GBK)-整站商业源码.zip
实训商业源码-效能-毕业设计.zip
平台跳跃游戏的核心魅力在于重力与控制的精妙平衡。本文将构建角色运动的微分方程模型,解析空中机动算法,并揭示关卡设计中的隐式引力场理论,展现2D平台游戏背后的复杂物理模拟系统。
实训商业源码-签到工具-毕业设计.zip
nsync///////
实训商业源码-票务高级版4.2.9-毕业设计.zip
运算符重载函数(友元函数).cpp
ABAQUS模型定义.pdf
FreeRTOS计数信号量的使用,模拟停车场运行逻辑
毕业论文-方熊表单V1.0.0 开源版-整站商业源码.zip
毕业论文-多商户线下积分商城会员群发V2.5.11 原版-整站商业源码.zip
实训商业源码-新材料-毕业设计.zip
毕业论文-活码自动进群V1.0.0 开源版-整站商业源码.zip
毕业论文-红包拓客生意宝2.0.3 开源版-整站商业源码.zip
Baidunetdisk_AndroidPhone_1023843j (6).apk
【研华科技】以数智融合打造可持续管理的企业未来.pdf
毕业论文-老虎-微信淘宝客6.0.3+老虎-团队合伙人系统2.99.83-整站商业源码.zip