springBoot项目里获取resource目录下的文件(可用于各种linux服务器部署)【我】
@PostMapping("/downExcelTemple") public String downOrderItemExcelTemple(@RequestBody Map<String,String> reqMap, HttpServletResponse response) throws Exception { log.info("下载导入模板req:{}",reqMap); // ADSL_templet.xls String templateName = reqMap.get("tmpName"); // 获取文件 InputStream inputStream=this.getClass().getResourceAsStream("/static/execlTemplateDown/"+templateName); ExcelUtil.downLoad(inputStream,templateName,response); return "ok"; }
流转文件
InputStream inputStreamXls = FtpUtil.downloadFile(hdfsHost, hdfsPort, hdfsUsername, hdfsPassword, xlsPath, xlsName); logMap.put("inputStreamXls","xls路径:"+xlsPath+"流:"+inputStreamXls.toString()); File fileXls = new File(System.currentTimeMillis()+""+(int)(Math.random()*900)+100+".xls"); FileUtils.copyInputStreamToFile(inputStreamXls,fileXls); String realXlsPath = fileXls.getAbsolutePath();