我想使用java代码下载位于Temp \ hello.csv位置服务器上的CSV文件
答案 0 :(得分:0)
@RequestMapping("/download")
public StreamingResponseBody handle() {
return new StreamingResponseBody() {
@Override
public void writeTo(OutputStream outputStream) throws IOException {
File file=new File("Temp\hello.csv");
FileInputStream stream =new FileInputStream(file);
IOUtils.copy(stream, outputStream);
}
};
}
但还有许多其他功能。 (Spring boot service to download a file,Downloading a file from spring controllers,...)