Tabnine Logo
Streams.copyToString
Code IndexAdd Tabnine to your IDE (free)

How to use
copyToString
method
in
org.elasticsearch.common.io.Streams

Best Java code snippets using org.elasticsearch.common.io.Streams.copyToString (Showing top 14 results out of 315)

origin: com.strapdata.elasticsearch.test/framework

public static String copyToStringFromClasspath(ClassLoader classLoader, String path) throws IOException {
  InputStream is = classLoader.getResourceAsStream(path);
  if (is == null) {
    throw new FileNotFoundException("Resource [" + path + "] not found in classpath with class loader [" + classLoader + "]");
  }
  return Streams.copyToString(new InputStreamReader(is, StandardCharsets.UTF_8));
}
origin: tlrx/elasticsearch-test

  @Override
  public String toString() {
    try {
      if (klass != null) {
        InputStream inputStream = klass.getResourceAsStream(path);
        if (inputStream == null) {
          throw new FileNotFoundException("Resource [" + path + "] not found in classpath with class  [" + klass.getName() + "]");
        }
        return Streams.copyToString(new InputStreamReader(inputStream, "UTF-8"));
      } else {
        return Streams.copyToStringFromClasspath(classLoader, path);
      }
    } catch (IOException e) {
      throw new EsSetupRuntimeException(e);
    }
  }
}
origin: com.strapdata.elasticsearch.test/framework

public static String copyToStringFromClasspath(String path) throws IOException {
  InputStream is = Streams.class.getResourceAsStream(path);
  if (is == null) {
    throw new FileNotFoundException("Resource [" + path + "] not found in classpath");
  }
  return Streams.copyToString(new InputStreamReader(is, StandardCharsets.UTF_8));
}
origin: com.github.tlrx/elasticsearch-test

  @Override
  public String toString() {
    try {
      if (klass != null) {
        InputStream inputStream = klass.getResourceAsStream(path);
        if (inputStream == null) {
          throw new FileNotFoundException("Resource [" + path + "] not found in classpath with class  [" + klass.getName() + "]");
        }
        return Streams.copyToString(new InputStreamReader(inputStream, "UTF-8"));
      } else {
        return Streams.copyToStringFromClasspath(classLoader, path);
      }
    } catch (IOException e) {
      throw new EsSetupRuntimeException(e);
    }
  }
}
origin: javanna/elasticshell

Map<String, String> loadFromClasspath(String resourceName) throws IOException {
  InputStream is = this.getClass().getResourceAsStream(resourceName);
  if (is == null) {
    throw new FileNotFoundException("Unable to find file " + MESSAGES_FILE);
  }
  SettingsLoader settingsLoader = SettingsLoaderFactory.loaderFromResource(resourceName);
  return settingsLoader.load(Streams.copyToString(new InputStreamReader(is, "UTF-8")));
}
origin: com.strapdata.elasticsearch/elasticsearch

/**
 * Loads settings from a stream that represents them using the
 * {@link SettingsLoaderFactory#loaderFromResource(String)}.
 */
public Builder loadFromStream(String resourceName, InputStream is) throws IOException {
  SettingsLoader settingsLoader = SettingsLoaderFactory.loaderFromResource(resourceName);
  // NOTE: copyToString will close the input stream
  Map<String, String> loadedSettings =
    settingsLoader.load(Streams.copyToString(new InputStreamReader(is, StandardCharsets.UTF_8)));
  put(loadedSettings);
  return this;
}
origin: harbby/presto-connectors

/**
 * Loads settings from a stream that represents them using the
 * {@link SettingsLoaderFactory#loaderFromSource(String)}.
 */
public Builder loadFromStream(String resourceName, InputStream is) throws SettingsException {
  SettingsLoader settingsLoader = SettingsLoaderFactory.loaderFromResource(resourceName);
  try {
    Map<String, String> loadedSettings = settingsLoader.load(Streams.copyToString(new InputStreamReader(is, Charsets.UTF_8)));
    put(loadedSettings);
  } catch (Exception e) {
    throw new SettingsException("Failed to load settings from [" + resourceName + "]", e);
  }
  return this;
}
origin: com.github.tlrx/elasticsearch-view-plugin

found = true;
try {
  String view = Streams.copyToString(new InputStreamReader(new FileInputStream(file), "UTF-8"));
  viewEngine.load(viewName, view);
} catch (Exception e) {
origin: tlrx/elasticsearch-view-plugin

found = true;
try {
  String view = Streams.copyToString(new InputStreamReader(new FileInputStream(file), "UTF-8"));
  viewEngine.load(viewName, view);
} catch (Exception e) {
origin: org.elasticsearch.client/elasticsearch-rest-high-level-client

  return Streams.copyToString(new InputStreamReader(response.getEntity().getContent(), StandardCharsets.UTF_8));
} else {
origin: apache/servicemix-bundles

  return Streams.copyToString(new InputStreamReader(response.getEntity().getContent(), StandardCharsets.UTF_8));
} else {
origin: com.strapdata.elasticsearch/elasticsearch

logger.info("compiling script file [{}]", file.toAbsolutePath());
try (InputStreamReader reader = new InputStreamReader(Files.newInputStream(file), StandardCharsets.UTF_8)) {
  String script = Streams.copyToString(reader);
  String id = scriptNameExt.v1();
  CacheKey cacheKey = new CacheKey(engineService.getType(), id, null);
origin: harbby/presto-connectors

logger.info("compiling script file [{}]", file.toAbsolutePath());
try(InputStreamReader reader = new InputStreamReader(Files.newInputStream(file), Charsets.UTF_8)) {
  String script = Streams.copyToString(reader);
  CacheKey cacheKey = new CacheKey(engineService, scriptNameExt.v1(), null, Collections.<String, String>emptyMap());
  staticCache.put(cacheKey, new CompiledScript(ScriptType.FILE, scriptNameExt.v1(), engineService.types()[0], engineService.compile(script, Collections.<String, String>emptyMap())));
origin: org.elasticsearch.plugin/analysis-icu

Exception failureToResolve = null;
try {
  rules = Streams.copyToString(Files.newBufferedReader(environment.configFile().resolve(rules), Charset.forName("UTF-8")));
} catch (IOException | SecurityException e) {
  failureToResolve = e;
org.elasticsearch.common.ioStreamscopyToString

Javadoc

Copy the contents of the given Reader into a String. Closes the reader when done.

Popular methods of Streams

  • copy
    Copy the contents of the given byte array to the given OutputStream. Closes the stream when done.
  • copyToByteArray
  • readAllLines
  • readFully
  • flushOnCloseStream
    Wraps the given BytesStream in a StreamOutput that simply flushes when close is called.
  • copyToStringFromClasspath

Popular in Java

  • Making http requests using okhttp
  • getContentResolver (Context)
  • scheduleAtFixedRate (ScheduledExecutorService)
  • orElseThrow (Optional)
    Return the contained value, if present, otherwise throw an exception to be created by the provided s
  • Socket (java.net)
    Provides a client-side TCP socket.
  • URLEncoder (java.net)
    This class is used to encode a string using the format required by application/x-www-form-urlencoded
  • Timestamp (java.sql)
    A Java representation of the SQL TIMESTAMP type. It provides the capability of representing the SQL
  • SimpleDateFormat (java.text)
    Formats and parses dates in a locale-sensitive manner. Formatting turns a Date into a String, and pa
  • JComboBox (javax.swing)
  • LogFactory (org.apache.commons.logging)
    Factory for creating Log instances, with discovery and configuration features similar to that employ
  • Top 12 Jupyter Notebook extensions
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now