List of usage examples for com.google.common.io Resources asCharSource
public static CharSource asCharSource(URL url, Charset charset)
From source file:org.nmdp.ngs.sra.SraReader.java
/** * Read an experiment from the specified URL. * * @param url URL, must not be null/* w w w .j av a 2s . c o m*/ * @return an experiment read from the specified URL * @throws IOException if an I/O error occurs */ public static Experiment readExperiment(final URL url) throws IOException { checkNotNull(url); try (BufferedReader reader = Resources.asCharSource(url, Charsets.UTF_8).openBufferedStream()) { return readExperiment(reader); } }
From source file:de.monticore.MontiCoreScript.java
/** * Executes the default MontiCore Groovy script (parses grammars, generates * ASTs, parsers, etc.)./*from ww w . jav a2s. c om*/ * * @see Configuration * @param configuration of MontiCore for this execution * @see Configuration */ public void run(Configuration configuration) { try { ClassLoader l = MontiCoreScript.class.getClassLoader(); String script = Resources .asCharSource(l.getResource("de/monticore/monticore_emf.groovy"), Charset.forName("UTF-8")) .read(); run(script, configuration); } catch (IOException e) { Log.error("0xA1015 Failed to default MontiCore script.", e); } }
From source file:com.gradleware.tooling.toolingutils.distribution.PublishedGradleVersions.java
private static String downloadVersionInformation() { try {//w w w .j a v a2 s . c om return Resources.asCharSource(createURL(VERSIONS_URL), Charsets.UTF_8).read(); } catch (IOException e) { LOG.error("Cannot download published Gradle versions.", e); throw new RuntimeException("Cannot download published Gradle versions.", e); // throw an exception if version information cannot be downloaded since we need this information } }
From source file:org.nmdp.ngs.variant.vcf.VcfReader.java
/** * Read zero or more VCF records from the specified URL. * * @param url URL to read from, must not be null * @return zero or more VCF records read from the specified URL * @throws IOException if an I/O error occurs *//*from www . j a v a 2 s. c o m*/ public static Iterable<VcfRecord> records(final URL url) throws IOException { checkNotNull(url); try (BufferedReader reader = Resources.asCharSource(url, Charsets.UTF_8).openBufferedStream()) { return records(reader); } }
From source file:org.glowroot.local.ui.TraceExportHttpService.java
private static CharSource asCharSource(String exportResourceName) { URL url = Resources.getResource("org/glowroot/local/ui/export-dist/" + exportResourceName); return Resources.asCharSource(url, Charsets.UTF_8); }
From source file:org.dishevelled.bio.variant.vcf.VcfReader.java
/** * Read the VCF pedigree from the specified URL. * * @param url URL to read from, must not be null * @return the VCF pedigree read from the specified URL * @throws IOException if an I/O error occurs *///from w w w .j ava 2 s . co m public static VcfPedigree pedigree(final URL url) throws IOException { checkNotNull(url); try (BufferedReader reader = Resources.asCharSource(url, Charsets.UTF_8).openBufferedStream()) { return pedigree(reader); } }
From source file:com.google.template.soy.shared.SoyGeneralOptions.java
/** * Sets the resource file containing compile-time globals. * * <p> Each line of the file should have the format * <pre>/*w ww . j a v a2 s.c o m*/ * <global_name> = <primitive_data> * </pre> * where primitive_data is a valid Soy expression literal for a primitive type (null, boolean, * integer, float, or string). Empty lines and lines beginning with "//" are ignored. The file * should be encoded in UTF-8. * * <p> If you need to generate a file in this format from Java, consider using the utility * {@code SoyUtils.generateCompileTimeGlobalsFile()}. * * @param compileTimeGlobalsResource The resource file containing compile-time globals. * @throws IOException If there is an error reading the compile-time globals file. */ public void setCompileTimeGlobals(URL compileTimeGlobalsResource) throws IOException { setCompileTimeGlobalsInternal( SoyUtils.parseCompileTimeGlobals(Resources.asCharSource(compileTimeGlobalsResource, UTF_8))); }
From source file:org.nmdp.ngs.sra.SraReader.java
/** * Read a run set from the specified URL. * * @param url URL, must not be null/*from www. j ava2 s . co m*/ * @return a run set read from the specified URL * @throws IOException if an I/O error occurs */ public static RunSet readRunSet(final URL url) throws IOException { checkNotNull(url); try (BufferedReader reader = Resources.asCharSource(url, Charsets.UTF_8).openBufferedStream()) { return readRunSet(reader); } }
From source file:org.glowroot.ui.TraceExportHttpService.java
private static CharSource asCharSource(String exportResourceName) { URL url = TraceExportHttpService.class.getResource("/org/glowroot/ui/export-dist/" + exportResourceName); return Resources.asCharSource(checkNotNull(url), UTF_8); }
From source file:org.nmdp.ngs.sra.SraReader.java
/** * Read a sample from the specified URL. * * @param url URL, must not be null/* w ww . j a va 2s.c o m*/ * @return a sample read from the specified URL * @throws IOException if an I/O error occurs */ public static Sample readSample(final URL url) throws IOException { checkNotNull(url); try (BufferedReader reader = Resources.asCharSource(url, Charsets.UTF_8).openBufferedStream()) { return readSample(reader); } }