文件流读取磁盘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();
}
}

你可能感兴趣的:(servlet,F#)