org.springframework.core.io.PathResource Java Examples
The following examples show how to use
org.springframework.core.io.PathResource.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PropertiesUtil.java From DataLink with Apache License 2.0 | 6 votes |
/** * 获取properties文件内容 * * @param propertiesPath :绝对路径 * @return */ public static Properties getProperties(String propertiesPath) throws IOException { Properties resultProperties = propertiesMap.get(propertiesPath); if (resultProperties == null) { Resource resource = new PathResource(propertiesPath); try { resultProperties = PropertiesLoaderUtils.loadProperties(resource); } catch (FileNotFoundException e) { resultProperties = null; } if (resultProperties != null) propertiesMap.put(propertiesPath, resultProperties); } return resultProperties; }
Example #2
Source File: BatchJobConfiguration.java From patient-batch-loader with GNU General Public License v3.0 | 5 votes |
@Bean @StepScope public FlatFileItemReader<PatientRecord> reader( @Value("#{jobParameters['" + Constants.JOB_PARAM_FILE_NAME + "']}")String fileName) { return new FlatFileItemReaderBuilder<PatientRecord>() .name(Constants.ITEM_READER_NAME) .resource( new PathResource( Paths.get(applicationProperties.getBatch().getInputPath() + File.separator + fileName))) .linesToSkip(1) .lineMapper(lineMapper()) .build(); }
Example #3
Source File: ApplicationApi.java From haven-platform with Apache License 2.0 | 5 votes |
@RequestMapping(value = "{cluster}/{appId}/initFile", method = GET, produces = APPLICATION_OCTET_STREAM_VALUE) public ResponseEntity<Resource> getInitFile(@PathVariable("cluster") String cluster, @PathVariable("appId") String appId) { File initComposeFile = applicationService.getInitComposeFile(cluster, appId); log.info("fetching config file for application: {}, cluster: {}, path {}", appId, cluster, initComposeFile); if (!initComposeFile.exists()) { throw new NotFoundException("file not found " + initComposeFile); } HttpHeaders respHeaders = new HttpHeaders(); respHeaders.set("Content-Disposition", "attachment; filename=" + initComposeFile.getName()); respHeaders.setContentLength(initComposeFile.length()); return new ResponseEntity<>(new PathResource(initComposeFile.toPath()), respHeaders, HttpStatus.OK); }