List of usage examples for org.springframework.core.io Resource getInputStream
InputStream getInputStream() throws IOException;
From source file:my.custom.transformer.SourceModuleIntegrationTest.java
@Test public void test() throws IOException { SingleNodeProcessingChain chain = chain(application, "unZipStream", String.format("unZip")); final Resource resource = application.adminContext().getResource("classpath:testzipdata/single.zip"); final InputStream is = resource.getInputStream(); byte[] zipdata = IOUtils.toByteArray(is); //final Message<byte[]> message = MessageBuilder.withPayload(zipdata).build(); chain.sendPayload(zipdata);//from w w w .ja v a 2 s. c o m Object payload = chain.receivePayload(RECEIVE_TIMEOUT); System.out.println("payload: " + payload); //assertTrue(payload instanceof String); chain.destroy(); }
From source file:org.dkpro.lab.engine.impl.DefaultTaskExecutionService.java
@SuppressWarnings("unchecked") public void setMappingDescriptors(Resource[] aResources) throws ClassNotFoundException, IOException { final ClassLoader cl = getClass().getClassLoader(); for (final Resource res : aResources) { final Properties props = new Properties(); props.load(res.getInputStream()); for (final Object key : props.keySet()) { final String taskClass = (String) key; final String engineClass = props.getProperty(taskClass); map.put((Class<? extends Task>) Class.forName(taskClass, true, cl), (Class<? extends TaskExecutionEngine>) Class.forName(engineClass, true, cl)); }/*w ww .j a va2s . co m*/ } }
From source file:com.bluexml.side.framework.alfresco.commons.configurations.PropertiesConfiguration.java
protected void loadResource(Resource r) { if (r.exists()) { Properties properties = new Properties(); try {/* w w w . j a v a2s. com*/ properties.load(r.getInputStream()); logger.info("Load Properties form Resource " + r); } catch (IOException e) { logger.error("Unexpected error loading property file \"" + r.getFilename() + "\" ", e); } if (isValidePropertiesResource(properties)) { for (Object property : properties.keySet()) { String key = (String) property; String value = (String) properties.getProperty(key); dictionary.put(key, value); } } } else { logger.info("Resource do not exists :" + r.getDescription()); } }
From source file:net.longfalcon.newsj.Config.java
@Transactional(propagation = Propagation.SUPPORTS, isolation = Isolation.READ_COMMITTED) public void init() { properties = new Properties(); for (Resource resource : propertyLocations) { try {/* w w w . j av a2 s.co m*/ properties.load(resource.getInputStream()); } catch (IOException e) { _log.error("Unable to read from resource " + resource.getFilename()); } } defaultSite = siteDAO.getDefaultSite(); }
From source file:fi.helsinki.opintoni.integration.leiki.LeikiMockClient.java
public <T> List<T> getLeikiSearchResponse(Resource resource, TypeReference<LeikiResponse<T>> typeReference) { try {//from www . j ava 2 s . c o m LeikiResponse<T> response = objectMapper.readValue(resource.getInputStream(), typeReference); return response.data.items; } catch (IOException e) { throw new RuntimeException(e); } }
From source file:org.apache.crunch.dotfile.DotfileService.java
public String getDotfileContent(String fileName) throws IOException { for (Resource res : getResources()) { if (res.getFilename().contains(fileName)) { return IOUtils.toString(res.getInputStream()); // return Files.toString(res.getFile(), // Charset.forName("UTF-8")); }//from w w w .j a v a 2s.c om } return ""; }
From source file:eu.scape_project.archiventory.identifiers.DroidIdentification.java
/** * Constructor which initialises a given specified signature file * * @param sigFilePath// ww w . j ava 2 s . c o m */ public DroidIdentification(Resource resource) throws IOException { try { InputStream is = resource.getInputStream(); File tmpFile = IOUtils.copyInputStreamToTempFile(is, "DroidSignatureFile", ".xml"); tmpFile.deleteOnExit(); bsi = new BinarySignatureIdentifier(); bsi.setSignatureFile(tmpFile.getAbsolutePath()); bsi.init(); } catch (SignatureParseException ex) { logger.error("Signature parse error", ex); } }
From source file:com.springsource.hq.plugin.tcserver.plugin.serverconfig.environment.WindowsFileReadingEnvironmentFactory.java
private String createJavaHome(final Resource wrapperConf) throws IOException { BufferedReader envFileReader = new BufferedReader(new InputStreamReader(wrapperConf.getInputStream())); try {/* w w w. j a v a 2 s. c om*/ String line = envFileReader.readLine(); for (; line != null; line = envFileReader.readLine()) { if (line.trim().startsWith("set.JAVA_HOME") && line.indexOf("=") != -1) { return windowsOptsUtil.stripQuotes(line.substring(line.indexOf("=") + 1)); } } return null; } finally { envFileReader.close(); } }
From source file:de.hska.ld.core.service.impl.MailServiceImpl.java
@Autowired private void init() { String emailCfgLocation = env.getProperty("email.config.file"); Resource resource = context.getResource(emailCfgLocation); try {/*from w w w. j a v a 2 s.c o m*/ MAIL_PROPERTIES.load(resource.getInputStream()); } catch (Exception e) { System.err.println( "Java Mail Sender could not be initialized. Maybe the configuration file is not in place."); } }
From source file:it.tidalwave.northernwind.frontend.ui.component.DefaultStaticHtmlFragmentViewController.java
protected void populate(final @Nonnull String htmlResourceName, final @Nonnull Map<String, String> attributes) throws IOException { final Resource htmlResource = new ClassPathResource(htmlResourceName, getClass()); final @Cleanup Reader r = new InputStreamReader(htmlResource.getInputStream()); final CharBuffer charBuffer = CharBuffer.allocate((int) htmlResource.contentLength()); final int length = r.read(charBuffer); r.close();/* ww w . j a v a 2 s .co m*/ final String html = new String(charBuffer.array(), 0, length); ST template = new ST(html, '$', '$'); for (final Entry<String, String> entry : attributes.entrySet()) { template = template.add(entry.getKey(), entry.getValue()); } view.setContent(template.render()); }