List of usage examples for org.springframework.core.io Resource getInputStream
InputStream getInputStream() throws IOException;
From source file:com.thinkbiganalytics.feedmgr.rest.model.FeedMetadataJsonTest.java
@Test public void deserializationSortedTest() throws Exception { Resource r = new ClassPathResource("sorted-feed.json"); String json = IOUtils.toString(r.getInputStream(), Charset.defaultCharset()); FeedMetadata feed = ObjectMapperSerializer.deserialize(json, FeedMetadata.class); assertNotNull(feed);//from www . jav a 2 s .c om }
From source file:com.w3ma.m3u8web.config.ConfigManager.java
public ConfigManager() throws IOException { final Resource resource = new ClassPathResource("configuration.json"); final InputStream is = resource.getInputStream(); final Reader reader = new InputStreamReader(is); appConfiguration = new Gson().fromJson(reader, AppConfiguration.class); }
From source file:com.thinkbiganalytics.feedmgr.rest.model.FeedMetadataJsonTest.java
@Test public void deserializationUnsortedTest() throws Exception { Resource r = new ClassPathResource("unsorted-feed.json"); String json = IOUtils.toString(r.getInputStream(), Charset.defaultCharset()); FeedMetadata feed = ObjectMapperSerializer.deserialize(json, FeedMetadata.class); assertNotNull(feed);// ww w .j av a 2 s . c om }
From source file:io.wcm.devops.conga.tooling.maven.plugin.ValidateVersionInfoMojo.java
private Properties toProperties(Resource resource) { try (InputStream is = resource.getInputStream()) { Properties props = new Properties(); props.load(is);//from ww w . j av a2s.com return props; } catch (IOException ex) { throw new RuntimeException("Unable to read properties file: " + resource.toString(), ex); } }
From source file:at.porscheinformatik.common.spring.web.extended.template.chunk.ChunkTemplateTest.java
private String templateContent(Resource resource) { try (Reader in = new InputStreamReader(resource.getInputStream(), Charset.forName("UTF-8"))) { return IOUtils.toString(in); } catch (IOException ex) { throw new RuntimeException(ex); }// www. j a v a 2 s. com }
From source file:com.autentia.wuija.i18n.SequenceResource.java
/** * Devuelve un nico <code>InputStream</code> que es el resultado de concatenar todos los <code>InputStream</code> * de los <code>Resource</code> que se pasaron en el constructor. * <p>//from w ww . j a va 2 s . c o m * Para conseguir esto, esta clase utiliza la clase <code>java.io.SequenceInputStream</code> de Java. * * @return un nico <code>InputStream</code> que es el resultado de concatenar todos los <code>InputStream</code> de * los <code>Resource</code> que se pasaron en el constructor. */ public InputStream getInputStream() throws IOException { final List<InputStream> ins = new ArrayList<InputStream>(resources.length); for (Resource resource : resources) { ins.add(resource.getInputStream()); } final Enumeration<InputStream> streamsEnumeration = Collections.enumeration(ins); return new SequenceInputStream(streamsEnumeration); }
From source file:biz.deinum.multitenant.batch.item.excel.jxl.JxlItemReader.java
@Override protected void openExcelFile(final Resource resource) throws Exception { this.workbook = WorkbookParser.getWorkbook(resource.getInputStream()); }
From source file:com.jaxio.celerio.template.pack.ClasspathResourceUncryptedPackLoader.java
public List<TemplatePack> getPacks() { List<TemplatePack> packs = newArrayList(); try {/*from ww w . j a v a 2 s . c om*/ PathMatchingResourcePatternResolver o = new PathMatchingResourcePatternResolver(); Resource infos[] = o.getResources(CLASSPATH_CELERIO_PACK); for (Resource info : infos) { CelerioPack celerioPack = celerioPackConfigLoader.load(info.getInputStream()); TemplatePackInfo templatePackInfo = new TemplatePackInfo(celerioPack); Resource templatesAsResources[] = o .getResources("classpath*:/celerio/" + templatePackInfo.getName() + "/**/*"); packs.add(new ClasspathResourceUncryptedPack(templatePackInfo, templatesAsResources)); } return packs; } catch (IOException e) { throw new RuntimeException("Could not load the template packs", e); } }
From source file:com.logsniffer.util.grok.GrokAppConfig.java
@Bean public GroksRegistry groksRegistry() throws IOException, GrokException { GroksRegistry registry = new GroksRegistry(); PathMatchingResourcePatternResolver pathMatcher = new PathMatchingResourcePatternResolver(); Resource[] classPathPatterns = pathMatcher.getResources("classpath*:/grok-patterns/*"); Arrays.sort(classPathPatterns, new Comparator<Resource>() { @Override//from w w w . j a v a 2 s . c o m public int compare(final Resource o1, final Resource o2) { return o1.getFilename().compareTo(o2.getFilename()); } }); LinkedHashMap<String, String[]> grokBlocks = new LinkedHashMap<String, String[]>(); for (Resource r : classPathPatterns) { grokBlocks.put(r.getFilename(), IOUtils.readLines(r.getInputStream()).toArray(new String[0])); } registry.registerPatternBlocks(grokBlocks); return registry; }
From source file:org.nekorp.workflow.desktop.view.resource.imp.IconProviderImp.java
@Override public JPanel getIcon(String name) { BufferedImage img = cache.get(name); if (img == null) { try {/*w ww .j av a2s. c om*/ ResourcePatternResolver resourceResolver = new PathMatchingResourcePatternResolver(); Resource r = resourceResolver.getResource("/icon/" + name); img = ImageIO.read(r.getInputStream()); this.cache.put(name, img); } catch (IOException ex) { throw new IllegalArgumentException("el icono no se logro cargar", ex); } } ImagenViewer panel = new ImagenViewer(img); panel.setOpaque(false); return panel; }