List of usage examples for com.google.common.io Resources getResource
public static URL getResource(Class<?> contextClass, String resourceName)
From source file:org.apache.isis.schema.utils.ChangesDtoUtils.java
public static ChangesDto fromXml(final Class<?> contextClass, final String resourceName, final Charset charset) throws IOException { final URL url = Resources.getResource(contextClass, resourceName); final String s = Resources.toString(url, charset); return fromXml(new StringReader(s)); }
From source file:com.cognifide.aet.common.RedirectWriter.java
private String getContent(String reportUrl) throws IOException { String result;//w ww . j ava 2 s .c o m String template = Resources.toString(Resources.getResource(getClass(), TEMPLATE_RESOURCE_PATH), Charsets.UTF_8); result = template.replaceAll(REPORT_URL_PLACEHOLDER, reportUrl); return result; }
From source file:org.eclipse.che.selenium.core.utils.WorkspaceDtoDeserializer.java
public WorkspaceConfigDto deserializeWorkspaceTemplate(String templateName) { requireNonNull(templateName);/*from w w w.j ava2s.c om*/ try { URL url = Resources.getResource(WorkspaceDtoDeserializer.class, format("/templates/workspace/%s/%s", infrastructure, templateName)); return DtoFactory.getInstance().createDtoFromJson(Resources.toString(url, Charsets.UTF_8), WorkspaceConfigDto.class); } catch (IOException | IllegalArgumentException | JsonSyntaxException e) { LOG.error("Fail to read workspace template {} for infrastructure {} because {} ", templateName, infrastructure, e.getMessage()); throw new RuntimeException(e.getLocalizedMessage(), e); } }
From source file:org.apache.isis.viewer.wicket.ui.components.widgets.zclip.ZeroClipboardLink.java
private static ResourceStreamResource newSwfFileResource() { return new ResourceStreamResource( new UrlResourceStream(Resources.getResource(ZeroClipboardLink.class, FILE_NAME_SWF))); }
From source file:com.google.gitiles.DefaultRenderer.java
public DefaultRenderer(Map<String, String> globals, String staticPrefix, URL customTemplates) { super(new Function<String, URL>() { @Override/*from w w w .j a v a 2s.c o m*/ public URL apply(String name) { return Resources.getResource(Renderer.class, "templates/" + name); } }, globals, staticPrefix, customTemplates); SoyFileSet.Builder builder = new SoyFileSet.Builder().setCompileTimeGlobals(this.globals); for (URL template : templates) { builder.add(template); } tofu = builder.build().compileToTofu(); }
From source file:org.libreoffice.ci.gerrit.buildbot.servlets.DefaultRenderer.java
public DefaultRenderer(Map<String, String> globals, URL customTemplates, String siteTitle) { super(new Function<String, URL>() { @Override/*from w w w. j a v a2 s. c o m*/ public URL apply(String name) { return Resources.getResource(Renderer.class, "templates/" + name); } }, globals, customTemplates, siteTitle); SoyFileSet.Builder builder = new SoyFileSet.Builder().setCompileTimeGlobals(this.globals); for (URL template : templates) { builder.add(template); } tofu = builder.build().compileToTofu(); }
From source file:com.cloudera.oryx.app.serving.AbstractConsoleResource.java
@PostConstruct public final void loadHTML() throws IOException { StringBuilder htmlBuilder = new StringBuilder(10000); for (String resource : new String[] { "console-header.html.fragment", getConsoleResource(), "console-footer.html.fragment" }) { URL resourceURL = Resources.getResource(AbstractConsoleResource.class, resource); htmlBuilder.append(Resources.toString(resourceURL, StandardCharsets.UTF_8)); }/*from w w w. java 2 s.com*/ html = htmlBuilder.toString(); }
From source file:com.nesscomputing.migratory.loader.ClasspathLoader.java
@Override public Collection<URI> loadFolder(final URI folderUri, final String pattern) { try {/*w w w.j a v a 2 s . co m*/ final URI uriLocation = Resources.getResource(this.getClass(), folderUri.getPath()).toURI(); return loaderManager.loadFolder(uriLocation, pattern); } catch (URISyntaxException e) { throw new MigratoryException(Reason.INTERNAL, e); } }
From source file:org.apache.isis.schema.utils.CommandDtoUtils.java
public static CommandDto fromXml(final Class<?> contextClass, final String resourceName, final Charset charset) throws IOException { final URL url = Resources.getResource(contextClass, resourceName); final String s = Resources.toString(url, charset); return fromXml(new StringReader(s)); }
From source file:li.klass.fhem.service.DeviceConfigurationProvider.java
@Inject public DeviceConfigurationProvider() { try {//from w ww.j av a2 s . c om options = new JSONObject(Resources.toString( Resources.getResource(DeviceConfigurationProvider.class, "deviceConfiguration.json"), Charsets.UTF_8)); } catch (Exception e) { throw new RuntimeException(e); } }