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

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

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

origin: org.elasticsearch/elasticsearch

public static long copy(InputStream in, OutputStream out) throws IOException {
  return copy(in, out, new byte[BUFFER_SIZE]);
}
origin: org.elasticsearch/elasticsearch

public static List<String> readAllLines(InputStream input) throws IOException {
  final List<String> lines = new ArrayList<>();
  readAllLines(input, lines::add);
  return lines;
}
origin: org.elasticsearch/elasticsearch

public static int readFully(InputStream reader, byte[] dest) throws IOException {
  return readFully(reader, dest, 0, dest.length);
}
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: 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: org.elasticsearch/elasticsearch

CompressibleBytesOutputStream(BytesStream bytesStreamOutput, boolean shouldCompress) throws IOException {
  this.bytesStreamOutput = bytesStreamOutput;
  this.shouldCompress = shouldCompress;
  if (shouldCompress) {
    this.stream = CompressorFactory.COMPRESSOR.streamOutput(Streams.flushOnCloseStream(bytesStreamOutput));
  } else {
    this.stream = bytesStreamOutput;
  }
}
origin: sonian/elasticsearch-jetty

public JettyHttpServerRestRequest(HttpServletRequest request) throws IOException {
  this.request = request;
  this.opaqueId = request.getHeader("X-Opaque-Id");
  this.method = Method.valueOf(request.getMethod());
  this.params = new HashMap<String, String>();
  if (request.getQueryString() != null) {
    RestUtils.decodeQueryString(request.getQueryString(), 0, params);
  }
  content = new BytesArray(Streams.copyToByteArray(request.getInputStream()));
  request.setAttribute(REQUEST_CONTENT_ATTRIBUTE, content);
}
origin: richardwilly98/elasticsearch-river-mongodb

public static String getRiverVersion() {
  String version = "Undefined";
  try {
    String properties = Streams.copyToStringFromClasspath("/org/elasticsearch/river/mongodb/es-build.properties");
    Properties props = new Properties();
    props.load(new FastStringReader(properties));
    String ver = props.getProperty("version", "undefined");
    String hash = props.getProperty("hash", "undefined");
    if (!"undefined".equals(hash)) {
      hash = hash.substring(0, 7);
    }
    String timestamp = "undefined";
    String gitTimestampRaw = props.getProperty("timestamp");
    if (gitTimestampRaw != null) {
      timestamp = ISODateTimeFormat.dateTimeNoMillis().withZone(DateTimeZone.UTC).print(Long.parseLong(gitTimestampRaw));
    }
    version = String.format("version[%s] - hash[%s] - time[%s]", ver, hash, timestamp);
  } catch (Exception ex) {
  }
  return version;
}
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: 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: org.elasticsearch/elasticsearch

OutputStream unclosableOutputStream = Streams.flushOnCloseStream(bytesOutput());
XContentBuilder builder =
  new XContentBuilder(XContentFactory.xContent(responseContentType), unclosableOutputStream, includes, excludes);
origin: salyh/elasticsearch-security-plugin

public TomcatHttpServerRestRequest(final HttpServletRequest request)
    throws IOException {
  this.request = request;
  opaqueId = request.getHeader("X-Opaque-Id");
  method = Method.valueOf(request.getMethod());
  params = new HashMap<String, String>();
  log.debug("HttpServletRequest impl class: " + request.getClass());
  log.debug("HttpServletRequest ru: " + request.getRemoteUser());
  log.debug("HttpServletRequest up: " + request.getUserPrincipal());
  //log.debug("HttpServletRequest up: " + request.getUserPrincipal().getClass().toString());
  if (request.getQueryString() != null) {
    RestUtils.decodeQueryString(request.getQueryString(), 0,
        params);
  }
  content = new BytesArray(Streams.copyToByteArray(request
      .getInputStream()));
  request.setAttribute(REQUEST_CONTENT_ATTRIBUTE, content);
}
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: org.elasticsearch/elasticsearch

/**
 * Copy the contents of the given Reader into a String.
 * Closes the reader when done.
 *
 * @param in the reader to copy from
 * @return the String that has been copied to
 * @throws IOException in case of I/O errors
 */
public static String copyToString(Reader in) throws IOException {
  StringWriter out = new StringWriter();
  copy(in, out);
  return out.toString();
}
origin: org.elasticsearch/elasticsearch

public static int readFully(Reader reader, char[] dest) throws IOException {
  return readFully(reader, dest, 0, dest.length);
}
origin: org.elasticsearch/elasticsearch

int[] width = buildWidths(table, request, verbose, headers);
BytesStream bytesOut = Streams.flushOnCloseStream(channel.bytesOutput());
UTF8StreamWriter out = new UTF8StreamWriter().setOutput(bytesOut);
int lastHeader = headers.size() - 1;
origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.elasticsearch

public static List<String> readAllLines(InputStream input) throws IOException {
  final List<String> lines = new ArrayList<>();
  readAllLines(input, lines::add);
  return lines;
}
origin: jprante/elasticsearch-skywalker

long version = Long.parseLong(stateFile.getName().substring("global-".length()));
if (version > highestVersion) {
  byte[] data = Streams.copyToByteArray(new FileInputStream(stateFile));
  if (data.length == 0) {
    continue;
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: org.apache.servicemix.bundles/org.apache.servicemix.bundles.elasticsearch

public static long copy(InputStream in, OutputStream out) throws IOException {
  return copy(in, out, new byte[BUFFER_SIZE]);
}
org.elasticsearch.common.ioStreams

Javadoc

Simple utility methods for file and stream copying. All copy methods use a block size of 4096 bytes, and close all affected streams when done.

Mainly for use within the framework, but also useful for application code.

Most used methods

  • copyToString
    Copy the contents of the given Reader into a String. Closes the reader when done.
  • 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

  • Parsing JSON documents to java classes using gson
  • onRequestPermissionsResult (Fragment)
  • setRequestProperty (URLConnection)
  • getSupportFragmentManager (FragmentActivity)
  • Point (java.awt)
    A point representing a location in (x,y) coordinate space, specified in integer precision.
  • BufferedWriter (java.io)
    Wraps an existing Writer and buffers the output. Expensive interaction with the underlying reader is
  • ConnectException (java.net)
    A ConnectException is thrown if a connection cannot be established to a remote host on a specific po
  • Callable (java.util.concurrent)
    A task that returns a result and may throw an exception. Implementors define a single method with no
  • FileUtils (org.apache.commons.io)
    General file manipulation utilities. Facilities are provided in the following areas: * writing to a
  • Loader (org.hibernate.loader)
    Abstract superclass of object loading (and querying) strategies. This class implements useful common
  • Top 17 Plugins for Android Studio
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

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