Interesting Facts About Streams in Core Java Technology

Interesting Facts About Streams in Core Java Technology
share on
by Sanjeev Kapoor 08 Dec 2014

If you use Java, or are considering doing so, you are likely to have heard of the term ‘stream’. What is this? A stream is essentially data that you access in a sequence. Some of the most basic stream classes are Output Stream and Input Stream. The former lets us out data out to somewhere, whilst the latter allows us to bring data in from somewhere. The additional streams essentially add capabilities to the two basic ones that have been mentioned.

In this post we will take a look at some interesting facts in relation to Core Java Technology streams. This covers everything from not requiring lambda expressions, to streaming readers, to streaming random numbers, to streaming random stuff and streaming complex text. So, keep on reading to find out everything you need to know about it…

Streaming Readers – To begin with, Core Java Technology presents you with the option to stream readers. This is ideal because one of the most regular tasks for Java developers is to parse a file line by line. Java is ideal for stream processing because you have an option on that is lines (). This will turn I/O stream in to a stream of strings.

CIO/CTO or something else.
Let's help you with your IT project.

You Can Stream Random Stuff – You can stream random stuff when using Core Java Technology. Your streams do not need to be limited to collections or fixed lists. You can generate a Supplier lambda or an Iterator lambda that creates the values of the stream. After this you are then able to generate streams with methods on the java.util.steam.StreamSupport class.

You Can Stream Random Numbers – Leading on from the first point, you also have the ability to stream random numbers. When it comes to the java.util.Random, there are three new categories of methods on that class which you can stream. These are as follows doubles (), longs () and intls (). You can then set the total amount of random numbers streamed, seed and the bounds when using overloaded versions of those methods.

Streams Do Not Require Lambda Expressions – Did you know that you don’t actually need Lambda for your streams? You do have the option to go back to anonymous classes. Nevertheless, it is unlikely that most people would want to.

Streaming Complex Text – Last but not least, the fifth fact in relation to streams in Core Java Technology is in regards to streaming complex text. This option is extremely useful for your classpath or the million column CSV files. The following process can be used when the content is not line based on your text processing – use splitAsStream (CharSequence) method on your java.util.regex.Pattern.

To conclude, there are evidently a lot of interesting facts in relation to streams in Core Java Technology, and hopefully this post has enlightened you to some of them. From not requiring lambda expressions to the ability to stream random stuff, and streaming complex text to streaming readers, Java once again has outdone itself when it comes to the possibilities that are available.

Recent Posts

get in touch

We're here to help!

Terms of use
Privacy Policy
Cookie Policy
Site Map
2020 IT Exchange, Inc