pdf预览,后台返回文件流,前台超链接指向后台方法

try {

// exportpdf(loCoNo, response.getOutputStream());

response.setContentType("application/pdf");

FileInputStream in = new FileInputStream(new File("/opt/zxxd/frontend/core/www/HZS170921000015_DASHU_2018011916421834878834700.pdf"));

OutputStream out = response.getOutputStream();

byte[] b = new byte[9126];

while ((in.read(b))!=-1) {

out.write(b);

}

out.flush();

in.close();

out.close();

} catch (IOException e) {

throw new RuntimeException(e.getMessage(), e);

}

你可能感兴趣的:(Java,文件流)