List of usage examples for com.google.common.io Resources getResource
public static URL getResource(String resourceName)
From source file:com.tdunning.plume.local.eager.LocalPlume.java
@Override public PCollection<String> readResourceFile(String name) throws IOException { return LocalCollection.wrap(Resources.readLines(Resources.getResource(name), Charsets.UTF_8)); }
From source file:com.streamsets.datacollector.kafka.cluster.KafkaOriginSinglePartitionIT.java
private static String getPipelineJson() throws Exception { URI uri = Resources.getResource("kafka_origin_pipeline.json").toURI(); String pipelineJson = new String(Files.readAllBytes(Paths.get(uri)), StandardCharsets.UTF_8); pipelineJson = pipelineJson.replace("topicName", TOPIC); pipelineJson = pipelineJson.replaceAll("localhost:9092", KafkaTestUtil.getMetadataBrokerURI()); pipelineJson = pipelineJson.replaceAll("localhost:2181", KafkaTestUtil.getZkConnect()); pipelineJson = pipelineJson.replaceAll("STANDALONE", "CLUSTER_YARN_STREAMING"); return pipelineJson; }
From source file:com.streamsets.datacollector.kafka.standalone.KafkaOriginMultiPartitionPipelineOperationsIT.java
private static String getPipelineJson() throws Exception { URI uri = Resources.getResource("kafka_origin_pipeline_standalone.json").toURI(); String pipelineJson = new String(Files.readAllBytes(Paths.get(uri)), StandardCharsets.UTF_8); pipelineJson = pipelineJson.replace("topicName", TOPIC); pipelineJson = pipelineJson.replaceAll("localhost:9092", KafkaTestUtil.getMetadataBrokerURI()); pipelineJson = pipelineJson.replaceAll("localhost:2181", KafkaTestUtil.getZkConnect()); return pipelineJson; }
From source file:me.j360.trace.storage.elasticsearch.LazyClient.java
LazyClient(ElasticsearchStorage.Builder builder) { this.clusterName = builder.cluster; this.hosts = builder.hosts; try {/*from ww w .ja va2 s . c om*/ this.indexTemplate = Resources .toString(Resources.getResource("zipkin_template.json"), StandardCharsets.UTF_8) .replace("${__INDEX__}", builder.index) .replace("${__NUMBER_OF_SHARDS__}", String.valueOf(builder.indexShards)) .replace("${__NUMBER_OF_REPLICAS__}", String.valueOf(builder.indexReplicas)); } catch (IOException e) { throw new AssertionError("Error reading jar resource, shouldn't happen.", e); } }
From source file:com.pesegato.MonkeySheet.MSGlobals.java
protected void logBuildInfo() { try {/*from w w w. ja v a2s . c o m*/ java.net.URL u = Resources.getResource("monkeysheet.build.date"); String build = Resources.toString(u, Charsets.UTF_8); log.info("MonkeySheett build date:" + build); } catch (java.io.IOException e) { log.error("Error reading build info", e); } }
From source file:com.sismics.util.AdblockUtil.java
public void start() throws Exception { interactive = false;//w w w.j av a2 s. com 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:com.mapr.synth.samplers.StringSampler.java
protected void readDistribution(String resourceName) { try {/*from ww w. ja v a2 s .com*/ if (distribution.compareAndSet(null, new Multinomial<String>())) { Splitter onTab = Splitter.on("\t").trimResults(); for (String line : Resources.readLines(Resources.getResource(resourceName), Charsets.UTF_8)) { if (!line.startsWith("#")) { Iterator<String> parts = onTab.split(line).iterator(); String name = translate(parts.next()); double weight = Double.parseDouble(parts.next()); distribution.get().add(name, weight); } } } } catch (IOException e) { throw new RuntimeException("Couldn't read built-in resource file", e); } }
From source file:com.oath.auth.Utils.java
public static KeyStore getKeyStore(final String jksFilePath, final char[] password) throws Exception { final KeyStore keyStore = KeyStore.getInstance("JKS"); ///CLOVER:OFF if (Paths.get(jksFilePath).isAbsolute()) { // Can not cover this branch in unit test. Can not refer any files by absolute paths try (InputStream jksFileInputStream = new FileInputStream(jksFilePath)) { keyStore.load(jksFileInputStream, password); return keyStore; }/*from ww w.j a v a 2s .com*/ } ///CLOVER:ON try (InputStream jksFileInputStream = Resources.getResource(jksFilePath).openStream()) { keyStore.load(jksFileInputStream, password); return keyStore; } }
From source file:org.apache.giraph.utils.GiraphDepVersions.java
/** Constructor */ private GiraphDepVersions() { URL url = Resources.getResource(RESOURCE_NAME); properties = new Properties(); try {/* w ww . ja va2 s.co m*/ properties.load(url.openStream()); } catch (IOException e) { LOG.error("Could not read giraph versions from file " + RESOURCE_NAME); } }
From source file:org.spka.cursus.publish.website.Publisher.java
public Publisher(Collection<File> files) throws ImportException, ExportException, IOException { this.files.put(Constants.RESULTS_DIR + "/.htaccess", Resources.asByteSource(Resources.getResource(Constants.RESOURCE_PATH + ".htaccess"))); for (File file : files) { this.files.putAll(new ResultsPagesGenerator(file).getPages()); }/*from w w w . j a v a 2s.c o m*/ }