fusioncharts 서버 그림 다운로드

1298 단어 자바fusioncharts
public ActionForward exportImgOfFunction(ActionMapping mapping,
ActionForm form, HttpServletRequest request,
HttpServletResponse response) throws Exception{
String path = Thread.currentThread().getContextClassLoader().getResource("").getPath();
String absoluPath = path.substring(1,path.lastIndexOf("/WEB-INF"));
String filePath = absoluPath+"\\resources\\hostReport\\zhujixingneng.jpg";// , FCExporter_JPG.jsp
try {
response.setHeader("Content-Disposition", "attachment; filename="
+ URLEncoder.encode(" .jpg", "UTF-8"));
byte[] buffer = new byte[1024];
FileInputStream fis = new FileInputStream(new File(filePath));
OutputStream bos = response.getOutputStream();
int len = 0;
while ((len = fis.read(buffer)) != -1) {
bos.write(buffer, 0, len);
}
bos.flush();
bos.close();
fis.close();
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
//
File tempFile = new File(filePath);
if(tempFile.exists()){
tempFile.delete();
}
return null;
}

좋은 웹페이지 즐겨찾기