{"id":148,"date":"2019-01-21T14:54:03","date_gmt":"2019-01-21T14:54:03","guid":{"rendered":"https:\/\/www.kindsonthegenius.com\/java\/?p=148"},"modified":"2019-03-02T04:38:36","modified_gmt":"2019-03-02T04:38:36","slug":"24-java-streams","status":"publish","type":"post","link":"https:\/\/www.kindsonthegenius.com\/java\/24-java-streams\/","title":{"rendered":"Java &#8211; Streams"},"content":{"rendered":"<p>We would be taking about Java Streams in this lesson. Interestingly, the classes you need to work with streams are all available in the java.io package. A stream represents\u00a0 movement of data from source to destination. You probably have used streams when you write System.out.println().<\/p>\n<p>&nbsp;<\/p>\n<p>Now we would cover the following<\/p>\n<ol>\n<li><a href=\"#t1\">Introduction to Streams<\/a><\/li>\n<li><a href=\"#t2\">ByteStreams<\/a><\/li>\n<li><a href=\"#t3\">Character Streams<\/a><\/li>\n<li><a href=\"#t4\">Java Standard Streams<\/a><\/li>\n<\/ol>\n<p>&nbsp;<\/p>\n<h4><strong id=\"t1\">1. Introduction to Streams<\/strong><\/h4>\n<p>As mention, a stream of flow of data. It can be from source to destination.\u00a0 It can however be InputStream or OutputStream.<\/p>\n<p><strong>InputStream<\/strong>: Used to read data from source<\/p>\n<p><strong>OutputStream<\/strong>: Used to write date to a destination.<\/p>\n<p>Any other stream fall under either of the two. So let&#8217;s consider Byte streams and Character Streams.<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<h4><strong id=\"t2\">2. Byte Streams<\/strong><\/h4>\n<p>You use byte streams to read or write bytes of data. That is 8-bits of data. Although there are a number of classes that can be used with byte stream, however, the most common are FileInputStream and FileOutputStream.<\/p>\n<p>So let&#8217;s look at a program that uses these streams to manage file. The program would copy an input file into an output file<\/p>\n<p>&nbsp;<\/p>\n<pre style=\"margin: 0; line-height: 125%;\"><span style=\"color: #008800; font-weight: bold;\">import<\/span> <span style=\"color: #0e84b5; font-weight: bold;\">java.io.*<\/span><span style=\"color: #333333;\">;<\/span>\r\n\r\n<span style=\"color: #888888;\">\/\/Program to copy data <\/span>\r\n<span style=\"color: #888888;\">\/\/from InputStream to OuputStream<\/span>\r\n<span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #008800; font-weight: bold;\">class<\/span> <span style=\"color: #bb0066; font-weight: bold;\">FilesDemo<\/span> <span style=\"color: #333333;\">{<\/span>\r\n\r\n\t<span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #008800; font-weight: bold;\">static<\/span> <span style=\"color: #333399; font-weight: bold;\">void<\/span> <span style=\"color: #0066bb; font-weight: bold;\">main<\/span><span style=\"color: #333333;\">(<\/span>String<span style=\"color: #333333;\">[]<\/span> args<span style=\"color: #333333;\">)<\/span> <span style=\"color: #008800; font-weight: bold;\">throws<\/span> IOException <span style=\"color: #333333;\">{<\/span>\r\n\t\t\r\n\t\tFileInputStream fis <span style=\"color: #333333;\">=<\/span> <span style=\"color: #008800; font-weight: bold;\">null<\/span><span style=\"color: #333333;\">;<\/span>\r\n\t\tFileOutputStream fos <span style=\"color: #333333;\">=<\/span> <span style=\"color: #008800; font-weight: bold;\">null<\/span><span style=\"color: #333333;\">;<\/span>\r\n\t\t\r\n\t\t<span style=\"color: #008800; font-weight: bold;\">try<\/span> <span style=\"color: #333333;\">{<\/span>\r\n\t\t\tFile inFile <span style=\"color: #333333;\">=<\/span> <span style=\"color: #008800; font-weight: bold;\">new<\/span> File<span style=\"color: #333333;\">(<\/span><span style=\"background-color: #fff0f0;\">\"D:\/data\/in.txt\"<\/span><span style=\"color: #333333;\">);<\/span>\r\n\t\t\tFile outFile <span style=\"color: #333333;\">=<\/span> <span style=\"color: #008800; font-weight: bold;\">new<\/span> File<span style=\"color: #333333;\">(<\/span><span style=\"background-color: #fff0f0;\">\"D:\/data\/out.txt\"<\/span><span style=\"color: #333333;\">);<\/span>\t\r\n\t\t\t\r\n\t\t\tfis <span style=\"color: #333333;\">=<\/span> <span style=\"color: #008800; font-weight: bold;\">new<\/span> FileInputStream<span style=\"color: #333333;\">(<\/span>inFile<span style=\"color: #333333;\">);<\/span>\r\n\t\t\tfos <span style=\"color: #333333;\">=<\/span> <span style=\"color: #008800; font-weight: bold;\">new<\/span> FileOutputStream<span style=\"color: #333333;\">(<\/span>outFile<span style=\"color: #333333;\">);<\/span>\r\n\t\t\t\r\n\t\t\t<span style=\"color: #008800; font-weight: bold;\">while<\/span><span style=\"color: #333333;\">(<\/span>fis<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">read<\/span><span style=\"color: #333333;\">()<\/span> <span style=\"color: #333333;\">!=<\/span> <span style=\"color: #333333;\">-<\/span><span style=\"color: #0000dd; font-weight: bold;\">1<\/span><span style=\"color: #333333;\">)<\/span> <span style=\"color: #333333;\">{<\/span>\r\n\t\t\t\t<span style=\"color: #333399; font-weight: bold;\">int<\/span> content <span style=\"color: #333333;\">=<\/span> fis<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">read<\/span><span style=\"color: #333333;\">();<\/span>\r\n\t\t\t\tfos<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">write<\/span><span style=\"color: #333333;\">(<\/span>content<span style=\"color: #333333;\">);<\/span>\r\n\t\t\t\tSystem<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">out<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">println<\/span><span style=\"color: #333333;\">(<\/span><span style=\"background-color: #fff0f0;\">\"Writting Something\"<\/span><span style=\"color: #333333;\">);<\/span>\r\n\t\t\t<span style=\"color: #333333;\">}<\/span>\r\n\t\t\t\r\n\t\t\tSystem<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">out<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">println<\/span><span style=\"color: #333333;\">(<\/span><span style=\"background-color: #fff0f0;\">\"Bytes written to output\"<\/span><span style=\"color: #333333;\">);<\/span>\r\n\t\t\t\r\n\t\t<span style=\"color: #333333;\">}<\/span> <span style=\"color: #008800; font-weight: bold;\">finally<\/span> <span style=\"color: #333333;\">{<\/span>\r\n\t\t\tfis<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">close<\/span><span style=\"color: #333333;\">();<\/span>\r\n\t\t\tfos<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">close<\/span><span style=\"color: #333333;\">();<\/span>\r\n\t\t<span style=\"color: #333333;\">}<\/span>\r\n\t<span style=\"color: #333333;\">}<\/span>\r\n<span style=\"color: #333333;\">}<\/span>\r\n<\/pre>\n<p>Listing 1.0: Program the createa file copy using FileStream<\/p>\n<p>&nbsp;<\/p>\n<p>Before you run the code, you should already have a file in.txt in the location specified. Then after executing the code, you will have a second file out.txt. This new file have the same content as in in.txt.<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<h4><strong id=\"t3\">3. Character Streams<\/strong><\/h4>\n<p>Unlike the Byte stream, the Character streams are used to handle input and output of 16-bit unicode characters.<\/p>\n<p>Although there are many classes,\u00a0 the most common classes used for character streams are, FileReader and FileWriter. You need to know the difference in FileInputStream and FileReader. Also between FileOutputStreand FileWriter<\/p>\n<p>The difference is this:<\/p>\n<p>While FileInputStream reads 1 bye of data at a time, FileReader reads 2 bytes.Same applies to Filewritter. So we do the same thin using FileReader and FileWritter.<\/p>\n<p>&nbsp;<\/p>\n<p><!-- HTML generated using hilite.me --><\/p>\n<pre style=\"margin: 0; line-height: 125%;\"><span style=\"color: #008800; font-weight: bold;\">import<\/span> <span style=\"color: #0e84b5; font-weight: bold;\">java.io.*<\/span><span style=\"color: #333333;\">;<\/span>\r\n\r\n<span style=\"color: #888888;\">\/\/Program to copy data <\/span>\r\n<span style=\"color: #888888;\">\/\/from FileReader to FileWriter<\/span>\r\n<span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #008800; font-weight: bold;\">class<\/span> <span style=\"color: #bb0066; font-weight: bold;\">FilesDemo<\/span> <span style=\"color: #333333;\">{<\/span>\r\n\r\n\t<span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #008800; font-weight: bold;\">static<\/span> <span style=\"color: #333399; font-weight: bold;\">void<\/span> <span style=\"color: #0066bb; font-weight: bold;\">main<\/span><span style=\"color: #333333;\">(<\/span>String<span style=\"color: #333333;\">[]<\/span> args<span style=\"color: #333333;\">)<\/span> <span style=\"color: #008800; font-weight: bold;\">throws<\/span> IOException <span style=\"color: #333333;\">{<\/span>\r\n\t\t\r\n\t\tFileReader fr <span style=\"color: #333333;\">=<\/span> <span style=\"color: #008800; font-weight: bold;\">null<\/span><span style=\"color: #333333;\">;<\/span>\r\n\t\tFileWriter fw <span style=\"color: #333333;\">=<\/span> <span style=\"color: #008800; font-weight: bold;\">null<\/span><span style=\"color: #333333;\">;<\/span>\r\n\t\t\r\n\t\t<span style=\"color: #008800; font-weight: bold;\">try<\/span> <span style=\"color: #333333;\">{<\/span>\r\n\t\t\tFile inFile <span style=\"color: #333333;\">=<\/span> <span style=\"color: #008800; font-weight: bold;\">new<\/span> File<span style=\"color: #333333;\">(<\/span><span style=\"background-color: #fff0f0;\">\"D:\/data\/in.txt\"<\/span><span style=\"color: #333333;\">);<\/span>\r\n\t\t\tFile outFile <span style=\"color: #333333;\">=<\/span> <span style=\"color: #008800; font-weight: bold;\">new<\/span> File<span style=\"color: #333333;\">(<\/span><span style=\"background-color: #fff0f0;\">\"D:\/data\/out.txt\"<\/span><span style=\"color: #333333;\">);<\/span>\t\r\n\t\t\t\r\n\t\t\tfr <span style=\"color: #333333;\">=<\/span> <span style=\"color: #008800; font-weight: bold;\">new<\/span> FileReader<span style=\"color: #333333;\">(<\/span>inFile<span style=\"color: #333333;\">);<\/span>\r\n\t\t\tfw <span style=\"color: #333333;\">=<\/span> <span style=\"color: #008800; font-weight: bold;\">new<\/span> FileWriter<span style=\"color: #333333;\">(<\/span>outFile<span style=\"color: #333333;\">);<\/span>\r\n\t\t\t\r\n\t\t\t<span style=\"color: #008800; font-weight: bold;\">while<\/span><span style=\"color: #333333;\">(<\/span>fr<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">read<\/span><span style=\"color: #333333;\">()<\/span> <span style=\"color: #333333;\">!=<\/span> <span style=\"color: #333333;\">-<\/span><span style=\"color: #0000dd; font-weight: bold;\">1<\/span><span style=\"color: #333333;\">)<\/span> <span style=\"color: #333333;\">{<\/span>\r\n\t\t\t\t<span style=\"color: #333399; font-weight: bold;\">int<\/span> content <span style=\"color: #333333;\">=<\/span> fr<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">read<\/span><span style=\"color: #333333;\">();<\/span>\r\n\t\t\t\tfw<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">write<\/span><span style=\"color: #333333;\">(<\/span>content<span style=\"color: #333333;\">);<\/span>\r\n\t\t\t<span style=\"color: #333333;\">}<\/span>\r\n\t\t\t\r\n\t\t\tSystem<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">out<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">println<\/span><span style=\"color: #333333;\">(<\/span><span style=\"background-color: #fff0f0;\">\"File written to output\"<\/span><span style=\"color: #333333;\">);<\/span>\r\n\t\t\t\r\n\t\t<span style=\"color: #333333;\">}<\/span> <span style=\"color: #008800; font-weight: bold;\">finally<\/span> <span style=\"color: #333333;\">{<\/span>\r\n\t\t\tfr<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">close<\/span><span style=\"color: #333333;\">();<\/span>\r\n\t\t\tfw<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">close<\/span><span style=\"color: #333333;\">();<\/span>\r\n\t\t<span style=\"color: #333333;\">}<\/span>\r\n\t<span style=\"color: #333333;\">}<\/span>\r\n<span style=\"color: #333333;\">}<\/span>\r\n<\/pre>\n<p>Listing 1.1: Create a file copy using FileReader and FileWriter<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<h4><strong id=\"t4\">4. Java Standard Streams<\/strong><\/h4>\n<p>You probably have written a program that requires user to enter input from the keyboard. The program then displays an output to the screen. These are standard streams.<\/p>\n<p>&nbsp;<\/p>\n<p>Hence, there are three standard streams java provides.<\/p>\n<p><strong>Standard Input<\/strong><\/p>\n<p>This is the <strong>System.in<\/strong>. You use it to get user input. And the keyboards is normally used as the standard input.<\/p>\n<p>&nbsp;<\/p>\n<p><strong>Standard Output<\/strong><\/p>\n<p>You use this when you write System.out. Normally, used to write some output for the user to see. The computer display screen is used for this.<\/p>\n<p>&nbsp;<\/p>\n<p><strong>Standard Error<\/strong><\/p>\n<p>You use this to output error data that is generated by user program. If an error occurs, information is written using the Standard error stream. It is known as System.err and goes to the\u00a0 computer screen as well.<\/p>\n<p>For example the program below uses the InputStreamReader. It reads data from Standard Input. Then terminates when the user enters the character &#8216;q&#8217;<\/p>\n<p>&nbsp;<\/p>\n<pre style=\"margin: 0; line-height: 125%;\"><span style=\"color: #008800; font-weight: bold;\">import<\/span> <span style=\"color: #0e84b5; font-weight: bold;\">java.io.*<\/span><span style=\"color: #333333;\">;<\/span>\r\n\r\n<span style=\"color: #888888;\">\/\/Program using StandardInputStream <\/span>\r\n<span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #008800; font-weight: bold;\">class<\/span> <span style=\"color: #bb0066; font-weight: bold;\">FilesDemo<\/span> <span style=\"color: #333333;\">{<\/span>\r\n\r\n\t<span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #008800; font-weight: bold;\">static<\/span> <span style=\"color: #333399; font-weight: bold;\">void<\/span> <span style=\"color: #0066bb; font-weight: bold;\">main<\/span><span style=\"color: #333333;\">(<\/span>String<span style=\"color: #333333;\">[]<\/span> args<span style=\"color: #333333;\">)<\/span> <span style=\"color: #008800; font-weight: bold;\">throws<\/span> IOException <span style=\"color: #333333;\">{<\/span>\r\n\t\t\r\n\t\tInputStreamReader rd <span style=\"color: #333333;\">=<\/span> <span style=\"color: #008800; font-weight: bold;\">null<\/span><span style=\"color: #333333;\">;<\/span>\r\n\t\t\r\n\t\t<span style=\"color: #008800; font-weight: bold;\">try<\/span> <span style=\"color: #333333;\">{<\/span>\r\n\t\t\trd <span style=\"color: #333333;\">=<\/span> <span style=\"color: #008800; font-weight: bold;\">new<\/span> InputStreamReader<span style=\"color: #333333;\">(<\/span>System<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">in<\/span><span style=\"color: #333333;\">);<\/span>\r\n\t\t\tSystem<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">out<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">println<\/span><span style=\"color: #333333;\">(<\/span><span style=\"background-color: #fff0f0;\">\"Enter q to quit...\"<\/span><span style=\"color: #333333;\">);<\/span>\r\n\t\t\t\r\n\t\t\t<span style=\"color: #333399; font-weight: bold;\">char<\/span> ch<span style=\"color: #333333;\">;<\/span>\r\n\t\t\t<span style=\"color: #008800; font-weight: bold;\">do<\/span> <span style=\"color: #333333;\">{<\/span>\r\n\t\t\t\tch <span style=\"color: #333333;\">=<\/span> <span style=\"color: #333333;\">(<\/span><span style=\"color: #333399; font-weight: bold;\">char<\/span><span style=\"color: #333333;\">)<\/span>rd<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">read<\/span><span style=\"color: #333333;\">();<\/span>\r\n\t\t\t\tSystem<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">out<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">println<\/span><span style=\"color: #333333;\">(<\/span><span style=\"background-color: #fff0f0;\">\"You entered \"<\/span> <span style=\"color: #333333;\">+<\/span> ch<span style=\"color: #333333;\">);<\/span>\r\n\t\t\t<span style=\"color: #333333;\">}<\/span>\r\n\t\t\t<span style=\"color: #008800; font-weight: bold;\">while<\/span><span style=\"color: #333333;\">(<\/span>ch <span style=\"color: #333333;\">!=<\/span> <span style=\"color: #0044dd;\">'q'<\/span><span style=\"color: #333333;\">);<\/span>\r\n\t\t\t\r\n\t\t\tSystem<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">out<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">println<\/span><span style=\"color: #333333;\">(<\/span><span style=\"background-color: #fff0f0;\">\"Program terminated\"<\/span><span style=\"color: #333333;\">);<\/span>\r\n\t\t\t\r\n\t\t<span style=\"color: #333333;\">}<\/span> <span style=\"color: #008800; font-weight: bold;\">finally<\/span> <span style=\"color: #333333;\">{<\/span>\r\n\t\t\trd<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">close<\/span><span style=\"color: #333333;\">();<\/span>\r\n\t\t<span style=\"color: #333333;\">}<\/span>\r\n\t<span style=\"color: #333333;\">}<\/span>\r\n<span style=\"color: #333333;\">}<\/span>\r\n<\/pre>\n<p>Listing 1.2: Program using InputStreamReader<\/p>\n","protected":false},"excerpt":{"rendered":"<p>We would be taking about Java Streams in this lesson. Interestingly, the classes you need to work with streams are all available in the java.io &hellip; <\/p>\n","protected":false},"author":395,"featured_media":150,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[2],"tags":[],"class_list":["post-148","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-java-tutorial"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Java - Streams - Java Tutorials<\/title>\n<meta name=\"description\" content=\"We would cover Java Streams including Byte Streams, Characters Streams and Java Standard Streams. The we take some examples.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.kindsonthegenius.com\/java\/24-java-streams\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Java - Streams - Java Tutorials\" \/>\n<meta property=\"og:description\" content=\"We would cover Java Streams including Byte Streams, Characters Streams and Java Standard Streams. The we take some examples.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.kindsonthegenius.com\/java\/24-java-streams\/\" \/>\n<meta property=\"og:site_name\" content=\"Java Tutorials\" \/>\n<meta property=\"article:published_time\" content=\"2019-01-21T14:54:03+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2019-03-02T04:38:36+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.kindsonthegenius.com\/java\/wp-content\/uploads\/sites\/9\/2019\/01\/Streams-in-Java.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"950\" \/>\n\t<meta property=\"og:image:height\" content=\"518\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"kindsonthegenius\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"kindsonthegenius\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/java\\\/24-java-streams\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/java\\\/24-java-streams\\\/\"},\"author\":{\"name\":\"kindsonthegenius\",\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/java\\\/#\\\/schema\\\/person\\\/63a68934672db675ff0cd80d066510c2\"},\"headline\":\"Java &#8211; Streams\",\"datePublished\":\"2019-01-21T14:54:03+00:00\",\"dateModified\":\"2019-03-02T04:38:36+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/java\\\/24-java-streams\\\/\"},\"wordCount\":503,\"commentCount\":0,\"image\":{\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/java\\\/24-java-streams\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/java\\\/wp-content\\\/uploads\\\/sites\\\/9\\\/2019\\\/01\\\/Streams-in-Java.jpg\",\"articleSection\":[\"Java Tutorial\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.kindsonthegenius.com\\\/java\\\/24-java-streams\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/java\\\/24-java-streams\\\/\",\"url\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/java\\\/24-java-streams\\\/\",\"name\":\"Java - Streams - Java Tutorials\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/java\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/java\\\/24-java-streams\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/java\\\/24-java-streams\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/java\\\/wp-content\\\/uploads\\\/sites\\\/9\\\/2019\\\/01\\\/Streams-in-Java.jpg\",\"datePublished\":\"2019-01-21T14:54:03+00:00\",\"dateModified\":\"2019-03-02T04:38:36+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/java\\\/#\\\/schema\\\/person\\\/63a68934672db675ff0cd80d066510c2\"},\"description\":\"We would cover Java Streams including Byte Streams, Characters Streams and Java Standard Streams. The we take some examples.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/java\\\/24-java-streams\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.kindsonthegenius.com\\\/java\\\/24-java-streams\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/java\\\/24-java-streams\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/java\\\/wp-content\\\/uploads\\\/sites\\\/9\\\/2019\\\/01\\\/Streams-in-Java.jpg\",\"contentUrl\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/java\\\/wp-content\\\/uploads\\\/sites\\\/9\\\/2019\\\/01\\\/Streams-in-Java.jpg\",\"width\":950,\"height\":518,\"caption\":\"Streams in Java\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/java\\\/24-java-streams\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/java\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Java &#8211; Streams\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/java\\\/#website\",\"url\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/java\\\/\",\"name\":\"Java Tutorials\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/java\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/java\\\/#\\\/schema\\\/person\\\/63a68934672db675ff0cd80d066510c2\",\"name\":\"kindsonthegenius\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/3079a7f663b02e801d03cd075852a037af36bd179b5fbcd0603bae3dd7833a9b?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/3079a7f663b02e801d03cd075852a037af36bd179b5fbcd0603bae3dd7833a9b?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/3079a7f663b02e801d03cd075852a037af36bd179b5fbcd0603bae3dd7833a9b?s=96&d=mm&r=g\",\"caption\":\"kindsonthegenius\"},\"url\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/java\\\/author\\\/kindsonthegenius-2\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Java - Streams - Java Tutorials","description":"We would cover Java Streams including Byte Streams, Characters Streams and Java Standard Streams. The we take some examples.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.kindsonthegenius.com\/java\/24-java-streams\/","og_locale":"en_US","og_type":"article","og_title":"Java - Streams - Java Tutorials","og_description":"We would cover Java Streams including Byte Streams, Characters Streams and Java Standard Streams. The we take some examples.","og_url":"https:\/\/www.kindsonthegenius.com\/java\/24-java-streams\/","og_site_name":"Java Tutorials","article_published_time":"2019-01-21T14:54:03+00:00","article_modified_time":"2019-03-02T04:38:36+00:00","og_image":[{"width":950,"height":518,"url":"https:\/\/www.kindsonthegenius.com\/java\/wp-content\/uploads\/sites\/9\/2019\/01\/Streams-in-Java.jpg","type":"image\/jpeg"}],"author":"kindsonthegenius","twitter_card":"summary_large_image","twitter_misc":{"Written by":"kindsonthegenius","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.kindsonthegenius.com\/java\/24-java-streams\/#article","isPartOf":{"@id":"https:\/\/www.kindsonthegenius.com\/java\/24-java-streams\/"},"author":{"name":"kindsonthegenius","@id":"https:\/\/www.kindsonthegenius.com\/java\/#\/schema\/person\/63a68934672db675ff0cd80d066510c2"},"headline":"Java &#8211; Streams","datePublished":"2019-01-21T14:54:03+00:00","dateModified":"2019-03-02T04:38:36+00:00","mainEntityOfPage":{"@id":"https:\/\/www.kindsonthegenius.com\/java\/24-java-streams\/"},"wordCount":503,"commentCount":0,"image":{"@id":"https:\/\/www.kindsonthegenius.com\/java\/24-java-streams\/#primaryimage"},"thumbnailUrl":"https:\/\/www.kindsonthegenius.com\/java\/wp-content\/uploads\/sites\/9\/2019\/01\/Streams-in-Java.jpg","articleSection":["Java Tutorial"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.kindsonthegenius.com\/java\/24-java-streams\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.kindsonthegenius.com\/java\/24-java-streams\/","url":"https:\/\/www.kindsonthegenius.com\/java\/24-java-streams\/","name":"Java - Streams - Java Tutorials","isPartOf":{"@id":"https:\/\/www.kindsonthegenius.com\/java\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.kindsonthegenius.com\/java\/24-java-streams\/#primaryimage"},"image":{"@id":"https:\/\/www.kindsonthegenius.com\/java\/24-java-streams\/#primaryimage"},"thumbnailUrl":"https:\/\/www.kindsonthegenius.com\/java\/wp-content\/uploads\/sites\/9\/2019\/01\/Streams-in-Java.jpg","datePublished":"2019-01-21T14:54:03+00:00","dateModified":"2019-03-02T04:38:36+00:00","author":{"@id":"https:\/\/www.kindsonthegenius.com\/java\/#\/schema\/person\/63a68934672db675ff0cd80d066510c2"},"description":"We would cover Java Streams including Byte Streams, Characters Streams and Java Standard Streams. The we take some examples.","breadcrumb":{"@id":"https:\/\/www.kindsonthegenius.com\/java\/24-java-streams\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.kindsonthegenius.com\/java\/24-java-streams\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.kindsonthegenius.com\/java\/24-java-streams\/#primaryimage","url":"https:\/\/www.kindsonthegenius.com\/java\/wp-content\/uploads\/sites\/9\/2019\/01\/Streams-in-Java.jpg","contentUrl":"https:\/\/www.kindsonthegenius.com\/java\/wp-content\/uploads\/sites\/9\/2019\/01\/Streams-in-Java.jpg","width":950,"height":518,"caption":"Streams in Java"},{"@type":"BreadcrumbList","@id":"https:\/\/www.kindsonthegenius.com\/java\/24-java-streams\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.kindsonthegenius.com\/java\/"},{"@type":"ListItem","position":2,"name":"Java &#8211; Streams"}]},{"@type":"WebSite","@id":"https:\/\/www.kindsonthegenius.com\/java\/#website","url":"https:\/\/www.kindsonthegenius.com\/java\/","name":"Java Tutorials","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.kindsonthegenius.com\/java\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.kindsonthegenius.com\/java\/#\/schema\/person\/63a68934672db675ff0cd80d066510c2","name":"kindsonthegenius","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/3079a7f663b02e801d03cd075852a037af36bd179b5fbcd0603bae3dd7833a9b?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/3079a7f663b02e801d03cd075852a037af36bd179b5fbcd0603bae3dd7833a9b?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/3079a7f663b02e801d03cd075852a037af36bd179b5fbcd0603bae3dd7833a9b?s=96&d=mm&r=g","caption":"kindsonthegenius"},"url":"https:\/\/www.kindsonthegenius.com\/java\/author\/kindsonthegenius-2\/"}]}},"_links":{"self":[{"href":"https:\/\/www.kindsonthegenius.com\/java\/wp-json\/wp\/v2\/posts\/148","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.kindsonthegenius.com\/java\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.kindsonthegenius.com\/java\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.kindsonthegenius.com\/java\/wp-json\/wp\/v2\/users\/395"}],"replies":[{"embeddable":true,"href":"https:\/\/www.kindsonthegenius.com\/java\/wp-json\/wp\/v2\/comments?post=148"}],"version-history":[{"count":4,"href":"https:\/\/www.kindsonthegenius.com\/java\/wp-json\/wp\/v2\/posts\/148\/revisions"}],"predecessor-version":[{"id":153,"href":"https:\/\/www.kindsonthegenius.com\/java\/wp-json\/wp\/v2\/posts\/148\/revisions\/153"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.kindsonthegenius.com\/java\/wp-json\/wp\/v2\/media\/150"}],"wp:attachment":[{"href":"https:\/\/www.kindsonthegenius.com\/java\/wp-json\/wp\/v2\/media?parent=148"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.kindsonthegenius.com\/java\/wp-json\/wp\/v2\/categories?post=148"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.kindsonthegenius.com\/java\/wp-json\/wp\/v2\/tags?post=148"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}