Java 8 String Join

 Posted On  | Yashwant Chavan 

Java 8 added join() method in java.lang.String class to join Strings elements, It internally uses StringJoiner class for joining Strings elements.

It has two overloaded versions of join() methods. One accepts CharSequence elements and other accepts Iterable of CharSequence, it means you can pass List of String or an Array of String. Refer below three examples to join String values, list of string and an array of string.

Java 

Java 8 Stream Find and Replace File Content

 Posted On  | Yashwant Chavan 

In this tutorial you will learn how to find and replace file content using Java 8 Stream API. Read file as Stream then use map() method to returns new stream consisting of the results after replacing all occurrence of "foo" with "bar". then write this stream to file again.

Java 

Java 8 Stream Map

 Posted On  | Yashwant Chavan 

In this tutorial you will learn about Java 8 Stream.map() method. Its a just conversion method where number of elements in the input and output streams is the same. Lambda expression is used as a argument, it is used to deal with each individual element in the stream. Its return a new Stream object containing the modified elements. e.g. define expression as map(n -> n * n) or map(s -> s.toUpperCase())

Java 

Java 8 Stream.Builder.build()

 Posted On  | Yashwant Chavan 

Learn how to create Stream using Stream.Builder.build() method. java.util.stream.Stream.Builder.build() method builds the stream and transitioning this builder to the built state. An IllegalStateException is thrown if there are further attempts to operate on the builder after it has entered the built state.

Java 

Java 8 Stream min() and max()

 Posted On  | Yashwant Chavan 

In this tutorial you will learn about min() and max() methods which returns an Optional instance. To obtain the value from Optional instance use get() method. It will return null value if stream has no elements. The min() and max() methods take a Comparator as a input parameter which compares the values using Comparator.comparing() method.

Java 

Java 8 Stream read File line by line

 Posted On  | Yashwant Chavan 

In this tutorials you will learn how to read File content line by line using Java 8 stream API's. Files.lines(Path path) method reads all lines from a file as a stream, and bytes from the file are decoded into characters using the standard charset.

Java 

Java 8 Stream extract distinct words from File

 Posted On  | Yashwant Chavan 

In this tutorial you will learn how to extract distinct words from file using Java 8 Stream API. Files.lines() method returns a stream of strings from a specified file. Then further, we use to read each lines and splitting the words with the help of regular expression. Once all the words are separated then extract the distinct words from all the elements of the single stream produced by the flatMap().

Java 

Java 8 Tutorials

 Posted On  | Yashwant Chavan 

Learn Java 8 streams by example with filter, map, flatMap, reduce, collect, lambdas, sequential and parallel streams are covered in-depth along with examples in this tutorial.

Java 8 

Java 8 Stream Find

 Posted On  | Yashwant Chavan 

In this tutorial you will learn about finding elements in a Stream base on Predicate condition with the help of Stream.findAny() and Stream.findFirst() methods.

Java 

Java 8 Stream Match

 Posted On  | Yashwant Chavan 

In this tutorial you will learn about matching elements in a Stream base on Predicate condition with the help of Stream.allMatch(), Stream.anyMatch() and Stream.noneMatch() methods.

Java 


© technicalkeeda.com 2018

 |  Find us on Google+ |  Rss Feed

Loaded in 0.0348 seconds.