我正在尝试将java.nio.file.Files功能用于以下代码
@RequestMapping(value = "/view", method = RequestMethod.GET)
public HttpServletResponse viewReport(Map model, HttpServletRequest req,HttpServletResponse rep){
try {
ReportGenerationService reportGenerationService = new ReportGenerationService();
ViewReportParameters viewReportParameters = reportGenerationService.getReportViewParameters();
String quote="\"";
String inlineFileName = "inline; fileName="+quote+viewReportParameters.getFileName()+".pdf"+quote;
File file = new File(filePath);
rep.setHeader("Content-Type", "application/pdf");
rep.setHeader("Content-Length", String.valueOf(file.length()));
rep.setHeader("Content-Disposition", inlineFileName);
Files.copy(file.toPath(), rep.getOutputStream());
} catch (IOException e) {
e.printStackTrace();
}
return rep;
}
但是由于linux box jdk版本较旧(Java 6),我无法使用它。有没有其他方法可以在Java 6中执行类似的操作?提前致谢