首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

资料流读取磁盘word

2012-12-23 
文件流读取磁盘word/* * 输出流到合同管理 */public void doPost(HttpServletRequest request, HttpServle

文件流读取磁盘word
/*
* 输出流到合同管理
*/
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException {

try {
//String test =request.getParameter("unm")
//Integer contractId = Integer.valueOf();
int contractId = 2;
ContractInfoService contractInfoService = new ContractInfoService();
// 得到服务器path读流
String path = null;
path = contractInfoService.getPath(contractId);
javax.servlet.ServletOutputStream outpt = response
.getOutputStream();
File f = new File(path);
FileInputStream fi = new FileInputStream(f);
byte[] aa = new byte[4 * 1024];
int b;
while ((b = fi.read(aa, 0, 4 * 1024)) != -1) {
System.out.println("b:" + b);
outpt.write(aa, 0, b);
}
outpt.flush();
response.flushBuffer();
outpt.close();
} catch (SQLException e) {
e.printStackTrace();
}
}

热点排行