赞
踩
- import lombok.extern.slf4j.Slf4j;
- import org.springframework.web.bind.annotation.PostMapping;
- import org.springframework.web.bind.annotation.RequestMapping;
- import org.springframework.web.bind.annotation.RestController;
-
- import javax.servlet.ServletOutputStream;
- import javax.servlet.http.HttpServletResponse;
- import java.io.File;
- import java.io.FileInputStream;
-
- @RestController
- @RequestMapping("/downLoad")
- @Slf4j
- public class DemoController {
-
- @PostMapping("/file")
- public static void downLoadFile(HttpServletResponse response){
- String filePath="E:\\羊肉产品.zip";
- ServletOutputStream out = null;
- FileInputStream in = null;
- try {
- in = new FileInputStream(new File(filePath));
- String[] dir = filePath.split("/");
- String fileName = dir[dir.length-1];
- String[] array = fileName.split("[.]");
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。