List of usage examples for org.springframework.core.io Resource getInputStream
InputStream getInputStream() throws IOException;
From source file:org.trustedanalytics.servicebroker.gearpump.service.file.ResourceManagerService.java
public InputStream getResourceInputStream(String path) throws IOException { Resource resource = getResourceForPath(path); LOGGER.info("Got the resource: {}", resource.getURI()); return resource.getInputStream(); }
From source file:egovframework.rte.bat.core.item.file.EgovByteReaderFactory.java
/** * Resource encoding? Reader ? /* w ww . j a v a2s. co m*/ * @param resource * @param encoding * @return * @throws UnsupportedEncodingException * @throws IOException */ public EgovByteReader create(Resource resource, String encoding) throws UnsupportedEncodingException, IOException { return new EgovByteReader(resource.getInputStream(), encoding); }
From source file:fi.helsinki.opintoni.integration.coursepage.CoursePageMockClient.java
public <T> T getResponse(Resource resource, TypeReference<T> typeReference) { try {/*from w w w. j a v a 2s .c o m*/ return objectMapper.readValue(resource.getInputStream(), typeReference); } catch (IOException e) { throw new RuntimeException(e); } }
From source file:com.opengamma.component.AbstractComponentConfigLoader.java
/** * Reads lines from the resource.//from ww w . j a v a2 s . co m * * @param resource the resource to read, not null * @return the lines, not null */ protected List<String> readLines(Resource resource) { try { return IOUtils.readLines(resource.getInputStream(), "UTF8"); } catch (IOException ex) { throw new OpenGammaRuntimeException("Unable to read resource: " + resource, ex); } }
From source file:org.swarmcom.jsynapse.TestBase.java
public void postAndCompareResult(String path, Resource req, Resource res) throws Exception { try (InputStream request = req.getInputStream()) { try (InputStream response = res.getInputStream()) { mockMvc.perform(post(path).contentType(APPLICATION_JSON).content(IOUtils.toString(request))) .andExpect(status().isOk()) .andExpect(content().string(deleteWhitespace(IOUtils.toString(response)))).andReturn(); }// w w w .j av a 2s . c o m } }
From source file:org.sglover.nlp.SpringClasspathModelLoader.java
public InputStream load(String modelFilePath) throws IOException { if (modelFilePath.startsWith("classpath:")) { modelFilePath = "classpath:" + modelFilePath; }//from w w w . j ava 2 s. c o m Resource resource = applicationContext.getResource(modelFilePath); InputStream in = resource != null ? resource.getInputStream() : null; return in; }
From source file:org.swarmcom.jsynapse.TestBase.java
public void postAndCheckStatus(String path, Resource req, HttpStatus status) throws Exception { try (InputStream request = req.getInputStream()) { mockMvc.perform(post(path).contentType(APPLICATION_JSON).content(IOUtils.toString(request))) .andExpect(status().is(status.value())).andReturn(); }/*www . j a v a2 s . co m*/ }
From source file:org.swarmcom.jsynapse.TestBase.java
public void deleteAndCheckStatus(String path, Resource req, HttpStatus status) throws Exception { try (InputStream request = req.getInputStream()) { mockMvc.perform(delete(path).contentType(APPLICATION_JSON).content(IOUtils.toString(request))) .andExpect(status().is(status.value())).andReturn(); }/*from w w w. j av a2s .co m*/ }
From source file:org.swarmcom.jsynapse.TestBase.java
public void putAndCheckStatus(String path, Resource req, HttpStatus status) throws Exception { try (InputStream request = req.getInputStream()) { mockMvc.perform(put(path).contentType(APPLICATION_JSON).content(IOUtils.toString(request))) .andExpect(status().is(status.value())).andReturn(); }//from w ww . j a v a2s . c o m }
From source file:CA.InternalCA.java
@Bean public X509CertificateHolder x509CertificateHolder() throws IOException { //Get file from resources folder Resource resource = new ClassPathResource("certs/root/ca.cer.der"); return readCert(resource.getInputStream()); }