public ActionForward exportFile(ActionMapping mapping, ActionForm form, HttpServletRequest request,
HttpServletResponse response) throws Exception {
String natLog = "test";
try {
StringBuilder fileName = null;
OutputStream output = null;
byte[] streamBytes = natLog.getBytes();
if (streamBytes == null) {
} else {
fileName = new StringBuilder(64);
fileName.append("export.txt");
try {
output = response.getOutputStream();
FileStream.initResponseAsFile(response, fileName.toString(), "MIME/octet-strea");
output.write(streamBytes);
output.flush();
} catch (Exception e) {
e.printStackTrace();
} finally {
if (output != null) {
output.close();
}
}
}
}
catch(Exception e) {
e.printStackTrace();
return null;
}
return null;
}
|