Java Stream Operation toString(LongStream ls)

Here you can find the source of toString(LongStream ls)

Description

Consumes all the values provided by the passed LongStream, displaying them as an array of values (on a single line).

License

Apache License

Parameter

Parameter Description
ls the LongStream.

Return

a String representation of the LongStream.

Declaration

public static String toString(LongStream ls) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.util.stream.LongStream;

public class Main {
    /**/*w ww . jav  a2s .  c o m*/
     * Consumes all the values provided by the passed LongStream, displaying them
     * as an array of values (on a single line).
     * 
     * @param ls
     *          the LongStream.
     * @return a String representation of the LongStream.
     */
    public static String toString(LongStream ls) {
        StringBuilder sb = new StringBuilder("[");
        ls.peek(sb::append).peek(n -> sb.append(", ")).filter(n -> false).findAny();
        String output = sb.substring(0, sb.length() - 2);
        return output + "]";
    }
}

Related

  1. startsWith(Stream stream, Stream stream2)
  2. stringPositions(StringBuilder toTest, Stream strings)
  3. toList(final Stream stream)
  4. toParameter(Stream input, Class exp)
  5. toString(IntStream s)
  6. upcastStream(Stream stream)
  7. zip(List> streams)
  8. zipWithIndex(Stream stream, int startIndex)