Tabnine Logo
Arrays.stream
Code IndexAdd Tabnine to your IDE (free)

How to use
stream
method
in
java.util.Arrays

Best Java code snippets using java.util.Arrays.stream (Showing top 20 results out of 30,663)

Refine searchRefine arrow

  • Stream.collect
  • Stream.map
  • Collectors.toList
  • Stream.filter
  • Stream.forEach
  • Stream.toArray
  • Collectors.joining
canonical example by Tabnine

public long getDirectorySize(File file) {
 if (!file.exists()) {
  return 0;
 }
 if (file.isFile()) {
  return file.length();
 }
 File[] files;
 if (!file.isDirectory() || (files = file.listFiles()) == null) {
  return 0;
 }
 return Arrays.stream(files).mapToLong(f -> getDirectorySize(f)).sum();
}
origin: spring-projects/spring-framework

/**
 * Match handlers declared under a base package, e.g. "org.example".
 * @param packages one or more base package classes
 */
public Builder basePackage(String... packages) {
  Arrays.stream(packages).filter(StringUtils::hasText).forEach(this::addBasePackage);
  return this;
}
origin: stackoverflow.com

 Stream<String> streamString = Stream.of("a", "b", "c");
String[] stringArray = streamString.toArray(size -> new String[size]);
Arrays.stream(stringArray).forEach(System.out::println);
origin: apache/incubator-dubbo

/**
 * get routed invokers from result of script rule evaluation
 */
@SuppressWarnings("unchecked")
protected <T> List<Invoker<T>> getRoutedInvokers(Object obj) {
  if (obj instanceof Invoker[]) {
    return Arrays.asList((Invoker<T>[]) obj);
  } else if (obj instanceof Object[]) {
    return Arrays.stream((Object[]) obj).map(item -> (Invoker<T>) item).collect(Collectors.toList());
  } else {
    return (List<Invoker<T>>) obj;
  }
}
origin: prestodb/presto

private void printPlanNodesStatsAndCost(int indent, PlanNode... nodes)
{
  if (stream(nodes).allMatch(this::isPlanNodeStatsAndCostsUnknown)) {
    return;
  }
  print(indent, "Cost: %s", stream(nodes).map(this::formatPlanNodeStatsAndCost).collect(joining("/")));
}
origin: apache/incubator-druid

private static AggregatorFactory[] convertToCombiningFactories(AggregatorFactory[] metricsSpec)
{
 return Arrays.stream(metricsSpec)
        .map(AggregatorFactory::getCombiningFactory)
        .toArray(AggregatorFactory[]::new);
}
origin: spring-projects/spring-framework

@Override
public Stream<T> stream() {
  return Arrays.stream(getBeanNamesForTypedStream(requiredType))
      .map(name -> (T) getBean(name))
      .filter(bean -> !(bean instanceof NullBean));
}
@Override
origin: spring-projects/spring-framework

public void setCookies(@Nullable Cookie... cookies) {
  this.cookies = (ObjectUtils.isEmpty(cookies) ? null : cookies);
  this.headers.remove(HttpHeaders.COOKIE);
  if (this.cookies != null) {
    Arrays.stream(this.cookies)
        .map(c -> c.getName() + '=' + (c.getValue() == null ? "" : c.getValue()))
        .forEach(value -> doAddHeaderValue(HttpHeaders.COOKIE, value, false));
  }
}
origin: prestodb/presto

private static Method getSingleApplyMethod(Class lambdaFunctionInterface)
{
  checkCondition(lambdaFunctionInterface.isAnnotationPresent(FunctionalInterface.class), COMPILER_ERROR, "Lambda function interface is required to be annotated with FunctionalInterface");
  List<Method> applyMethods = Arrays.stream(lambdaFunctionInterface.getMethods())
      .filter(method -> method.getName().equals("apply"))
      .collect(toImmutableList());
  checkCondition(applyMethods.size() == 1, COMPILER_ERROR, "Expect to have exactly 1 method with name 'apply' in interface " + lambdaFunctionInterface.getName());
  return applyMethods.get(0);
}
origin: apache/incubator-druid

 private static String concat(FlatTextFormat format, String... values)
 {
  return Arrays.stream(values).collect(Collectors.joining(format.getDefaultDelimiter()));
 }
}
origin: spring-projects/spring-framework

private static Method getMethodForReturnType(Class<?> returnType) {
  return Arrays.stream(TestBean.class.getMethods())
      .filter(method -> method.getReturnType().equals(returnType))
      .findFirst()
      .orElseThrow(() ->
          new IllegalArgumentException("Unique return type not found: " + returnType));
}
origin: spring-projects/spring-framework

@Override
public DefaultDataBuffer write(ByteBuffer... buffers) {
  if (!ObjectUtils.isEmpty(buffers)) {
    int capacity = Arrays.stream(buffers).mapToInt(ByteBuffer::remaining).sum();
    ensureCapacity(capacity);
    Arrays.stream(buffers).forEach(this::write);
  }
  return this;
}
origin: apache/incubator-dubbo

/**
 * get routed invokers from result of script rule evaluation
 */
@SuppressWarnings("unchecked")
protected <T> List<Invoker<T>> getRoutedInvokers(Object obj) {
  if (obj instanceof Invoker[]) {
    return Arrays.asList((Invoker<T>[]) obj);
  } else if (obj instanceof Object[]) {
    return Arrays.stream((Object[]) obj).map(item -> (Invoker<T>) item).collect(Collectors.toList());
  } else {
    return (List<Invoker<T>>) obj;
  }
}
origin: spring-projects/spring-framework

@Nullable
private String getContentCodingKey(HttpServletRequest request) {
  String header = request.getHeader(HttpHeaders.ACCEPT_ENCODING);
  if (!StringUtils.hasText(header)) {
    return null;
  }
  return Arrays.stream(StringUtils.tokenizeToStringArray(header, ","))
      .map(token -> {
        int index = token.indexOf(';');
        return (index >= 0 ? token.substring(0, index) : token).trim().toLowerCase();
      })
      .filter(this.contentCodings::contains)
      .sorted()
      .collect(Collectors.joining(","));
}
origin: apache/flink

  private static TypeSerializer<?>[] snapshotsToRestoreSerializers(TypeSerializerSnapshot<?>... snapshots) {
    return Arrays.stream(snapshots)
        .map(TypeSerializerSnapshot::restoreSerializer)
        .toArray(TypeSerializer[]::new);
  }
}
origin: codecentric/spring-boot-admin

@Nullable
@SafeVarargs
private final BuildVersion updateBuildVersion(Map<String, ?>... sources) {
  return Arrays.stream(sources).map(BuildVersion::from).filter(Objects::nonNull).findFirst().orElse(null);
}
origin: apache/incubator-dubbo

public CompositeConfiguration(Configuration... configurations) {
  if (configurations != null && configurations.length > 0) {
    Arrays.stream(configurations).filter(config -> !configList.contains(config)).forEach(configList::add);
  }
}
origin: spring-projects/spring-framework

public void setCookies(@Nullable Cookie... cookies) {
  this.cookies = (ObjectUtils.isEmpty(cookies) ? null : cookies);
  this.headers.remove(HttpHeaders.COOKIE);
  if (this.cookies != null) {
    Arrays.stream(this.cookies)
        .map(c -> c.getName() + '=' + (c.getValue() == null ? "" : c.getValue()))
        .forEach(value -> doAddHeaderValue(HttpHeaders.COOKIE, value, false));
  }
}
origin: spring-projects/spring-framework

@Override
public Builder cookie(HttpCookie... cookies) {
  Arrays.stream(cookies).forEach(cookie -> this.cookies.add(cookie.getName(), cookie));
  return this;
}
origin: prestodb/presto

public List<String> getIndices(ElasticsearchTableDescription tableDescription)
{
  if (tableDescription.getIndexExactMatch()) {
    return ImmutableList.of(tableDescription.getIndex());
  }
  TransportClient client = clients.get(tableDescription.getClusterName());
  verify(client != null, "client is null");
  String[] indices = getIndices(client, new GetIndexRequest());
  return Arrays.stream(indices)
        .filter(index -> index.startsWith(tableDescription.getIndex()))
        .collect(toImmutableList());
}
java.utilArraysstream

Popular methods of Arrays

  • asList
    Returns a List of the objects in the specified array. The size of the List cannot be modified, i.e.
  • toString
    Returns a string representation of the contents of the specified array. The string representation co
  • equals
    Returns true if the two specified arrays of booleans areequal to one another. Two arrays are conside
  • sort
    Sorts the specified range of the array into ascending order. The range to be sorted extends from the
  • copyOf
    Copies the specified array, truncating or padding with false (if necessary) so the copy has the spec
  • fill
    Assigns the specified boolean value to each element of the specified array of booleans.
  • hashCode
    Returns a hash code based on the contents of the specified array. For any two boolean arrays a and
  • copyOfRange
    Copies the specified range of the specified array into a new array. The initial index of the range (
  • binarySearch
    Searches the specified array of shorts for the specified value using the binary search algorithm. Th
  • deepEquals
    Returns true if the two specified arrays are deeply equal to one another. Unlike the #equals(Object[
  • deepToString
  • deepHashCode
    Returns a hash code based on the "deep contents" of the specified array. If the array contains other
  • deepToString,
  • deepHashCode,
  • setAll,
  • parallelSort,
  • parallelSetAll,
  • spliterator,
  • checkBinarySearchBounds,
  • checkOffsetAndCount,
  • checkStartAndEnd

Popular in Java

  • Creating JSON documents from java classes using gson
  • runOnUiThread (Activity)
  • scheduleAtFixedRate (ScheduledExecutorService)
  • startActivity (Activity)
  • Rectangle (java.awt)
    A Rectangle specifies an area in a coordinate space that is enclosed by the Rectangle object's top-
  • BufferedInputStream (java.io)
    A BufferedInputStream adds functionality to another input stream-namely, the ability to buffer the i
  • FileNotFoundException (java.io)
    Thrown when a file specified by a program cannot be found.
  • LinkedList (java.util)
    Doubly-linked list implementation of the List and Dequeinterfaces. Implements all optional list oper
  • JButton (javax.swing)
  • Options (org.apache.commons.cli)
    Main entry-point into the library. Options represents a collection of Option objects, which describ
  • Best plugins for Eclipse
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