List of usage examples for org.springframework.core.io Resource getInputStream
InputStream getInputStream() throws IOException;
From source file:io.spring.batch.DownloadingStepExecutionListener.java
@Override public void beforeStep(StepExecution stepExecution) { String fileName = (String) stepExecution.getExecutionContext().get("fileName"); Resource resource = this.resourceLoader.getResource(fileName); try {/*w ww.ja v a 2 s . c om*/ File file = File.createTempFile("input", ".csv"); StreamUtils.copy(resource.getInputStream(), new FileOutputStream(file)); stepExecution.getExecutionContext().put("localFile", file.getAbsolutePath()); System.out.println(">> downloaded file : " + file.getAbsolutePath()); } catch (IOException e) { e.printStackTrace(); } }
From source file:com.springsource.hq.plugin.tcserver.plugin.serverconfig.environment.WindowsFileReadingEnvironmentFactory.java
private JvmOptions createJvmOptions(final Resource wrapperConf) throws IOException { BufferedReader envFileReader = new BufferedReader(new InputStreamReader(wrapperConf.getInputStream())); try {//from w w w . j a va 2 s . c om List<String> jvmOpts = new LinkedList<String>(); String line = envFileReader.readLine(); for (; line != null; line = envFileReader.readLine()) { if (line.trim().startsWith("wrapper.java.additional")) { jvmOpts.add(windowsOptsUtil.stripQuotes(line.trim().substring(line.indexOf("=") + 1))); } } jvmOpts = windowsOptsUtil.removeProtectedOpts(jvmOpts); return jvmOptionsConverter.convert(jvmOpts); } finally { envFileReader.close(); } }
From source file:org.codehaus.marmalade.msp.finder.FileBasedScriptFinder.java
public Reader getScript(HttpServletRequest request) throws IOException { validateState();//from w ww .ja v a 2 s. co m String path = request.getRequestURI(); System.out.println("Request path: " + path); if (pathInterpreter != null) { path = pathInterpreter.interpret(path); } if (!path.startsWith("/")) { path = "/" + path; } System.out.println("Interpreted path: " + path); path = basePath + path; System.out.println("Full path: " + path); Reader result = null; if (appContext != null) { Resource scriptResource = appContext.getResource(path); result = new BufferedReader(new InputStreamReader(scriptResource.getInputStream())); } else { result = new BufferedReader(new FileReader(path)); } System.out.println("Returning reader for file: " + path); return result; }
From source file:org.jasig.portlet.widget.service.GoogleGadgetServiceTest.java
@Test public void testGetModule() throws IOException { Resource gadgetXml = context.getResource("org/jasig/portlet/widget/service/googlecalendarviewer.xml"); doReturn(gadgetXml.getInputStream()).when(service).getStreamFromUrl(anyString()); Module module = service.getModule("http://pretend"); assertEquals("Google Calendar Viewer", module.getModulePrefs().getTitle()); }
From source file:org.jasig.portlet.widget.service.GoogleGadgetServiceTest.java
@Test public void testGetCategories() throws IOException { Resource mainPage = context.getResource("org/jasig/portlet/widget/service/gadgetListingMainPage.html"); doReturn(mainPage.getInputStream()).when(service).getStreamFromUrl(anyString()); List<GadgetCategory> categories = service.getCategories(); assertEquals(10, categories.size()); }
From source file:org.keycloak.adapters.springsecurity.config.AppConfig.java
@Bean KeycloakDeployment keycloakDeployment(/* www .j a va 2s .c om*/ @Value("${keycloak.configurationFile:WEB-INF/keycloak.json}") Resource keycloakConfigFileResource) throws IOException { return KeycloakDeploymentBuilder.build(keycloakConfigFileResource.getInputStream()); }
From source file:com.fns.grivet.service.NamedQueryServiceSelectTest.java
@Test public void testCreateThenGetHappyPath() throws IOException { Resource r = resolver.getResource("classpath:TestSelectQuery.json"); String json = IOUtils.toString(r.getInputStream(), Charset.defaultCharset()); NamedQuery namedQuery = objectMapper.readValue(json, NamedQuery.class); namedQueryService.create(namedQuery); MultiValueMap<String, String> params = new LinkedMultiValueMap<>(); params.add("createdTime", LocalDateTime.now().plusDays(1).toString()); String result = namedQueryService.get("getAttributesCreatedBefore", params); String[] expected = { "bigint", "varchar", "decimal", "datetime", "int", "text", "json", "boolean" }; List<String> actual = JsonPath.given(result).getList("name"); Assertions.assertTrue(actual.containsAll(Arrays.asList(expected))); }
From source file:eu.scape_project.up2ti.identifiers.DroidIdentification.java
/** * Constructor which initialises a given specified signature file * * @param sigFilePath//from w ww .j a v a2 s . co m */ public DroidIdentification(Resource resource) throws IOException { try { InputStream is = resource.getInputStream(); File tmpFile1 = File.createTempFile("DroidSignatureFile", ".xml"); FileUtils.copyInputStreamToFile(is, tmpFile1); File tmpFile = tmpFile1; tmpFile.deleteOnExit(); bsi = new BinarySignatureIdentifier(); bsi.setSignatureFile(tmpFile.getAbsolutePath()); bsi.init(); } catch (SignatureParseException ex) { LOG.error("Signature parse error", ex); } }
From source file:com.haoocai.jscheduler.core.shared.JschedulerConfig.java
@PostConstruct public void init() { Resource configFile = applicationContext.getResource(configPath); Properties properties = new Properties(); try {/*from www . j ava 2 s . c o m*/ properties.load(configFile.getInputStream()); } catch (IOException e) { LOG.info("load properties error:{}.", e.getMessage(), e); } connectStr = properties.getProperty("connectStr"); namespaces = Splitter.on(",").omitEmptyStrings().trimResults() .splitToList(properties.getProperty("namespace")); }
From source file:org.cloudfoundry.identity.api.web.ApiController.java
/** * @param info the info to set//from w w w. ja va 2 s . co m */ public void setInfo(Resource info) { try { this.infoResource = FileCopyUtils.copyToString(new InputStreamReader(info.getInputStream())); } catch (IOException e) { throw new IllegalArgumentException("Could not load template", e); } }