日期:2014-05-18 浏览次数:20889 次
public InputStream getDocumentInputStrame() throws FileNotFoundException{
String downFilePathServletActionContext.getServletContext()
.getRealPath("/");//文件路径
downloadFileName=tenderfile.getFilename();//文件名称
downloadFileName=this.getFileEcodingName(downloadFileName);//调用action的方法传入参数,对文件名称进行编码解码。
StringBuffer sb=new StringBuffer();
sb.append(downFilePath).append(downloadFileName);
File file=new File(sb.toString());
InputStream in=new FileInputStream(file);
return in;//返回输入流
}
public String getFileEcodingName(String downloadFileName) {
try {
downloadFileName=new String(downloadFileName.getBytes(),"ISO-8859-1");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
} return downloadFileName;
}