java获取文件流
@RequestMapping(value = "preView", method = RequestMethod.GET)
public void preView(HttpServletResponse response){
File file = new File("C:\\Users\\admin\\Desktop\\新建文本文档.txt");
if (file.exists()){
byte[] data = null;
try {
FileInputStream input = new FileInputStream(file);
data = new byte[input.available()];
input.read(data);
response.getOutputStream().write(data);
input.close();
} catch (Exception e) {
System.out.println(e);
}
}else{
return;
}
}