List of usage examples for com.google.common.io Resources toString
public static String toString(URL url, Charset charset) throws IOException
From source file:org.apache.isis.core.unittestsupport.jaxb.JaxbMatchers.java
public static <T> T fromXml(final Class<?> contextClass, final String resourceName, final Charset charset, final Class<T> dtoClass) throws IOException { final URL url = Resources.getResource(contextClass, resourceName); final String s = Resources.toString(url, charset); return fromXml(new StringReader(s), dtoClass); }
From source file:org.cloudifysource.cosmo.orchestrator.workflow.config.RuoteRuntimeConfig.java
private static String getContent(String resource) throws IOException { final URL url = Resources.getResource(resource); return Resources.toString(url, Charsets.UTF_8); }
From source file:com.google.api.codegen.config.ApiDefaultsConfig.java
public static ApiDefaultsConfig load() throws IOException { URL apiDefaultsUrl = ApiDefaultsConfig.class .getResource("/com/google/api/codegen/packaging/api_defaults.yaml"); String contents = Resources.toString(apiDefaultsUrl, StandardCharsets.UTF_8); return createFromString(contents); }
From source file:com.greensopinion.finance.services.web.EulaWebService.java
@Path(CURRENT_EULA) @GET// w w w . ja v a 2 s . c om public Eula current() { try { return new Eula(Resources.toString(Resources.getResource(EulaWebService.class, "model/eula.html"), StandardCharsets.UTF_8)); } catch (IOException e) { throw Throwables.propagate(e); } }
From source file:org.sonar.squidbridge.rules.ExternalDescriptionLoader.java
@VisibleForTesting void addHtmlDescription(NewRule rule, URL resource) { try {/*from www. j a va2s .c om*/ rule.setHtmlDescription(Resources.toString(resource, Charsets.UTF_8)); } catch (IOException e) { throw new IllegalStateException("Failed to read: " + resource, e); } }
From source file:com.google.testing.security.firingrange.utils.Templates.java
private static String templateToString(URL resource) { try {/* w w w . j a v a 2 s .c om*/ return Resources.toString(resource, UTF_8); } catch (IOException e) { logger.severe("Cannot open template: " + resource); return "ERROR, cannot open template"; } }
From source file:org.eclipse.scada.vi.ui.draw2d.loader.StaticSymbolLoader.java
@Override public String loadStringResource(final String url) throws Exception { final String target = resolveUri(url); logger.debug("Loading resource from: {}", target); //$NON-NLS-1$ return Resources.toString(new URL(target), Charset.forName("UTF-8")); //$NON-NLS-1$ }
From source file:com.sismics.util.AdblockUtil.java
public void start() throws Exception { interactive = false;//from w w w . j a va2s . co m js = new JSEngine(); URL url = Resources.getResource("adblock" + File.separator + "js" + File.separator + "start.js"); js.put("_locale", Locale.getDefault().toString()); js.put("_datapath", ""); js.put("_separator", File.separator); js.put("_version", ""); js.put("Android", new Helper(js)); js.evaluate(Resources.toString(url, Charsets.UTF_8)); }
From source file:de.vonengel.g930beat.AboutController.java
private void initTextArea() { URL resource = AboutController.class.getResource("/" + CONTENT_FILE); assert resource != null : "Could not load " + CONTENT_FILE; try {// w ww . jav a 2 s . co m String text = Resources.toString(resource, Charsets.UTF_8); aboutTextArea.setText(text); } catch (IOException e) { LOG.error("Could not load " + CONTENT_FILE, e); } }
From source file:com.google.caja.plugin.BrowserTestCatalog.java
public BrowserTestCatalog(URL url) throws IOException { String json = Resources.toString(url, Charsets.UTF_8); List<Entry> entriesAcc = new ArrayList<Entry>(); RhinoTestBed.runJs(new ParserOutput(entriesAcc), new Executor.Input(BrowserTestCatalog.class, "catalog-parser.js"), new Executor.Input("parseTestCatalog(" + json + ", caja___, true)", "<BrowserTestCatalog stub>")); entries = Collections.unmodifiableList(entriesAcc); entriesByLabel = Maps.uniqueIndex(entries, new Function<Entry, String>() { @Override/*from w w w . j av a2 s.co m*/ public String apply(Entry entry) { return entry.getLabel(); } }); }