{"id":14768,"date":"2023-03-22T10:29:03","date_gmt":"2023-03-22T10:29:03","guid":{"rendered":"https:\/\/www.prepbytes.com\/blog\/?p=14768"},"modified":"2023-08-17T12:39:46","modified_gmt":"2023-08-17T12:39:46","slug":"streams-in-java","status":"publish","type":"post","link":"https:\/\/prepbytes.com\/blog\/streams-in-java\/","title":{"rendered":"Streams in Java"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1679404599043-Streams%20in%20Java.jpg\" alt=\"\" \/><\/p>\n<p>Streams are a powerful feature introduced in Java 8 that revolutionized the way we work with collections and data manipulation. Streams provide a concise and functional way to perform operations on data, making code more readable, maintainable, and efficient. Whether you&#8217;re dealing with lists, arrays, or any collection, streams offer a modern approach to transform, filter, and process data. Let\u2019s discuss what is stream in Java, and also types of streams in Java.<\/p>\n<h2>What are Streams in Java?<\/h2>\n<p>A java stream is a group of objects that can be piped together to produce the desired result.<br \/>\nStreams are used in Java to transfer data between programs and I\/O devices like a file, network connections, or consoles.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1679404599148-1-01%20%2814%29.png\" alt=\"\" \/><\/p>\n<h2>What are the different Types of Streams in Java?<\/h2>\n<p>There are two types of java streams:<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1679404599149-1-02%20%2810%29.png\" alt=\"\" \/><\/p>\n<h3>1. Byte Streams<\/h3>\n<p>ByteStream classes are used to read bytes from and write bytes to an input stream. To put it another way, ByteStream classes read and write 8-bit data. Using ByteStream classes, we can save video, audio, characters, and so on. The java.io package contains these classes.<\/p>\n<p>Byte Java streams have a three-phase mechanism:<\/p>\n<ul>\n<li><strong>Split:<\/strong> A spliterator divides the input data source into a stream. The Java Spliterator interface is an internal iterator that divides the stream into smaller parts for traversal.<\/li>\n<li><strong>Apply:<\/strong> The elements in the stream are processed.<\/li>\n<li><strong>Combine:<\/strong> After the elements have been processed, they are combined once more to produce a single result.<\/li>\n<\/ul>\n<p><img decoding=\"async\" src=\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1679404599149-1-03%20%287%29.png\" alt=\"\" \/><\/p>\n<p>The ByteStream classes are classified into two types: InputStream and OutputStream. These are the abstract super classes for all Input\/Output stream classes.<\/p>\n<ul>\n<li>\n<p><strong>InputStream:<\/strong><br \/>\nThis type of java stream reads data from a source. An InputStream can read data from a file, network connection, or any other I\/O device. An InputStream can be used to read data from a file<\/p>\n<p><strong>Syntax of InputStream:<\/strong><\/p>\n<pre><code>FileInputStream sourceStream = new FileInputStream(\"path_to_file\");<\/code><\/pre>\n<\/li>\n<li>\n<p><strong>OutputStream:<\/strong><br \/>\nThe outputstream is a  java stream that takes data from a Java program and sends or writes it to the destination (data sink). A data flow out of a program is represented by an output. The output stream connects a Java program to a data sink. A Java program writes or sends data to the data sink.<br \/>\nThe data flow from a data source to a Java program via an input stream. The data flow from a Java program to a data sink via an output stream.<\/p>\n<p><strong>Syntax of OutputStream:<\/strong><\/p>\n<pre><code>FileOutputStream targetStream = new FileOutputStream(\"path_to_file\");<\/code><\/pre>\n<p><strong>Example of Byte Java Stream:<\/strong><br \/>\nBelow we have the code implementation and explanation <\/p>\n\t\t\t\t\t\t<style>\r\n\t\t\t\t\r\n\t\t\t\t\t#tab_container_14698 {\r\n\toverflow:hidden;\r\n\tdisplay:block;\r\n\twidth:100%;\r\n\tborder:0px solid #ddd;\r\n\tmargin-bottom:30px;\r\n\t}\r\n\r\n#tab_container_14698 .tab-content{\r\n\tpadding:20px;\r\n\tborder: 1px solid #e6e6e6 !important;\r\n\tmargin-top: 0px;\r\n\tbackground-color:#ffffff !important;\r\n\tcolor: #000000 !important;\r\n\tfont-size:16px !important;\r\n\tfont-family: Open Sans !important;\r\n\t\r\n\t\tborder: 1px solid #e6e6e6 !important;\r\n\t}\r\n#tab_container_14698 .wpsm_nav-tabs {\r\n    border-bottom: 0px solid #ddd;\r\n}\r\n#tab_container_14698 .wpsm_nav-tabs > li.active > a, #tab_container_14698 .wpsm_nav-tabs > li.active > a:hover, #tab_container_14698 .wpsm_nav-tabs > li.active > a:focus {\r\n\tcolor: #000000 !important;\r\n\tcursor: default;\r\n\tbackground-color: #ffffff !important;\r\n\tborder: 1px solid #e6e6e6 !important;\r\n}\r\n\r\n#tab_container_14698 .wpsm_nav-tabs > li > a {\r\n    margin-right: 0px !important; \r\n    line-height: 1.42857143 !important;\r\n    border: 1px solid #d5d5d5 !important;\r\n    border-radius: 0px 0px 0 0 !important; \r\n\tbackground-color: #e8e8e8 !important;\r\n\tcolor: #000000 !important;\r\n\tpadding: 15px 18px 15px 18px !important;\r\n\ttext-decoration: none !important;\r\n\tfont-size: 14px !important;\r\n\ttext-align:center !important;\r\n\tfont-family: Open Sans !important;\r\n}\r\n#tab_container_14698 .wpsm_nav-tabs > li > a:focus {\r\noutline: 0px !important;\r\n}\r\n\r\n#tab_container_14698 .wpsm_nav-tabs > li > a:before {\r\n\tdisplay:none !important;\r\n}\r\n#tab_container_14698 .wpsm_nav-tabs > li > a:after {\r\n\tdisplay:none !important ;\r\n}\r\n#tab_container_14698 .wpsm_nav-tabs > li{\r\npadding:0px !important ;\r\nmargin:0px;\r\n}\r\n\r\n#tab_container_14698 .wpsm_nav-tabs > li > a:hover , #tab_container_14698 .wpsm_nav-tabs > li > a:focus {\r\n    color: #000000 !important;\r\n    background-color: #e8e8e8 !important;\r\n\tborder: 1px solid #d5d5d5 !important;\r\n\t\r\n}\r\n#tab_container_14698 .wpsm_nav-tabs > li > a .fa{\r\n\r\nmargin-right:5px !important;\r\n\r\nmargin-left:5px !important;\r\n\r\n\r\n}\r\n\r\n\t\t#tab_container_14698 .wpsm_nav-tabs a{\r\n\t\t\tbackground-image: none;\r\n\t\t\tbackground-position: 0 0;\r\n\t\t\tbackground-repeat: repeat-x;\r\n\t\t}\r\n\t\t\t\r\n\r\n\r\n#tab_container_14698 .wpsm_nav-tabs > li {\r\n    float: left;\r\n    margin-bottom: -1px !important;\r\n\tmargin-right:0px !important; \r\n}\r\n\r\n\r\n#tab_container_14698 .tab-content{\r\noverflow:hidden !important;\r\n}\r\n\r\n\r\n@media (min-width: 769px) {\r\n\r\n\t#tab_container_14698 .wpsm_nav-tabs > li{\r\n\t\tfloat:left !important ;\r\n\t\t\t\tmargin-right:-1px !important;\r\n\t\t\t\t\t}\r\n\t#tab_container_14698 .wpsm_nav-tabs{\r\n\t\tfloat:none !important;\r\n\t\tmargin:0px !important;\r\n\t}\r\n\r\n\t#tab_container_14698 .wpsm_nav-tabs > li {\r\n\t\t\t\t\r\n\t}\r\n\t#tab_container_14698 .wpsm_nav{\r\n\t\t\t}\r\n\r\n}\r\n\r\n\r\n\r\n@media (max-width: 768px) {\r\n\t#tab_container_14698 .wpsm_nav-tabs > li {\r\n\t\t\t\t\r\n\t}\r\n\t#tab_container_14698 .wpsm_nav{\r\n\t\t\t}\r\n}\r\n\r\n\r\n\t.wpsm_nav-tabs li:before{\r\n\t\tdisplay:none !important;\r\n\t}\r\n\r\n\t@media (max-width: 768px) {\r\n\t\t\t\t\r\n\t\t\t\t.wpsm_nav-tabs{\r\n\t\t\tmargin-left:0px !important;\r\n\t\t\tmargin-right:0px !important; \r\n\t\t\t\r\n\t\t}\r\n\t\t\t\t#tab_container_14698 .wpsm_nav-tabs > li{\r\n\t\t\tfloat:none !important;\r\n\t\t}\r\n\t\t\t\r\n\t}\t\t\t\t<\/style>\r\n\t\t\t\t<div id=\"tab_container_14698\" >\r\n\t \r\n\t\t\t\t\t<ul class=\"wpsm_nav wpsm_nav-tabs\" role=\"tablist\" id=\"myTab_14698\">\r\n\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t<li role=\"presentation\"  class=\"active\"  onclick=\"do_resize()\">\r\n\t\t\t\t\t\t\t\t<a href=\"#tabs_desc_14698_1\" aria-controls=\"tabs_desc_14698_1\" role=\"tab\" data-toggle=\"tab\">\r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<i class=\"fa fa-code\"><\/i> \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t<span>java<\/span>\r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t<\/a>\r\n\t\t\t\t\t\t\t<\/li>\r\n\t\t\t\t\t\t\t\t\t\t\t <\/ul>\r\n\r\n\t\t\t\t\t  <!-- Tab panes -->\r\n\t\t\t\t\t  <div class=\"tab-content\" id=\"tab-content_14698\">\r\n\t\t\t\t\t\t\t\t\t\t\t\t <div role=\"tabpanel\" class=\"tab-pane  in active \" id=\"tabs_desc_14698_1\">\r\n\t\t\t\t\t\t\t\t<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"java\">import java.io.*;   \r\npublic class ByteStreamExample\r\n{\r\n    public static void main(String[] args) throws IOException\r\n    {\r\n        FileInputStream sourceStream = null;\r\n        FileOutputStream targetStream = null;\r\n  \r\n        try \r\n        {\r\n            sourceStream = new FileInputStream(\"source.txt\");\r\n            targetStream = new FileOutputStream (\"destination.txt\");\r\n  \r\n            \/\/ Reading source file using read method \r\n            \/\/ and write to file byte by byte using write method\r\n            int temp;\r\n            while ((temp = sourceStream.read()) != -1)\r\n                targetStream.write((byte)temp);            \r\n        }\r\n        finally \r\n        {\r\n            if (sourceStream != null){\r\n                sourceStream.close();   \r\n            }\r\n            if (targetStream != null){           \r\n                targetStream.close(); \r\n            }\r\n        }\r\n    }\r\n}\r\n<\/pre>\t\t\t\t\t\t <\/div>\r\n\t\t\t\t\t\t\t\r\n\t\t\t\t\t <\/div>\r\n\t\t\t\t\t \r\n\t\t\t\t <\/div>\r\n <script>\r\n\t\tjQuery(function () {\r\n\t\t\tjQuery('#myTab_14698 a:first').tab('show')\r\n\t\t});\r\n\t\t\r\n\t\t\t\tjQuery(function(){\r\n\t\t\tvar b=\"fadeIn\";\r\n\t\t\tvar c;\r\n\t\t\tvar a;\r\n\t\t\td(jQuery(\"#myTab_14698 a\"),jQuery(\"#tab-content_14698\"));function d(e,f,g){\r\n\t\t\t\te.click(function(i){\r\n\t\t\t\t\ti.preventDefault();\r\n\t\t\t\t\tjQuery(this).tab(\"show\");\r\n\t\t\t\t\tvar h=jQuery(this).data(\"easein\");\r\n\t\t\t\t\tif(c){c.removeClass(a);}\r\n\t\t\t\t\tif(h){f.find(\"div.active\").addClass(\"animated \"+h);a=h;}\r\n\t\t\t\t\telse{if(g){f.find(\"div.active\").addClass(\"animated \"+g);a=g;}else{f.find(\"div.active\").addClass(\"animated \"+b);a=b;}}c=f.find(\"div.active\");\r\n\t\t\t\t});\r\n\t\t\t}\r\n\t\t});\r\n\t\t\r\n\r\n\t\tfunction do_resize(){\r\n\r\n\t\t\tvar width=jQuery( '.tab-content .tab-pane iframe' ).width();\r\n\t\t\tvar height=jQuery( '.tab-content .tab-pane iframe' ).height();\r\n\r\n\t\t\tvar toggleSize = true;\r\n\t\t\tjQuery('iframe').animate({\r\n\t\t\t    width: toggleSize ? width : 640,\r\n\t\t\t    height: toggleSize ? height : 360\r\n\t\t\t  }, 250);\r\n\r\n\t\t\t  toggleSize = !toggleSize;\r\n\t\t}\r\n\r\n\r\n\t<\/script>\r\n\t\t\t\t\r\n\t\t\t\n<p><strong>Output:<\/strong><\/p>\n<pre><code>101000010001111111<\/code><\/pre>\n<p><strong>Explanation<\/strong><br \/>\nLet&#8217;s look at an example of using Byte Stream to copy the contents of one file to another. In this example, we&#8217;ll make two FileInputStream and FileOutputStream objects.<br \/>\nThe names of the source and destination files are passed to the FileInputStream and FileOutputStream classes as parameters. The content of the source file is then copied to the destination file. Here we are Assuming that we have already created a file called source.txt with the following contents, When we run the above program, it will create a destination.txt file in the same directory as the program file, with the same content as source.txt. A FileAlreadyExistsException is thrown if a file with the same name already exists.<\/p>\n<\/li>\n<\/ul>\n<h3>2. Character Stream<\/h3>\n<p>The Character stream is used for 16-bit Unicode input and output operations. Character streams would be advantageous if we wanted to copy a text file containing characters from one source to another using streams because it deals with characters. Java characters are 2 bytes (or 16 bits) in size.CharacterStream classes are provided by the java.io package to overcome the limitations of ByteStream classes, which can only handle 8-bit bytes and are incompatible with working directly with Unicode characters. CharacterStream classes are used to work with Unicode characters that are 16 bits in length. They can work with characters, char arrays, and Strings.<\/p>\n<p>The CharacterStream classes, on the other hand, are primarily used to read characters from the source and write them to the destination. CharacterStream classes are divided into two types for this purpose: Reader classes and Writer classes.<\/p>\n<p>Character streams in Java, like Byte Streams, have a three-phase mechanism, as explained above.<\/p>\n<p>There are numerous character stream classes in Java, but the most common ones are-<\/p>\n<ul>\n<li>\n<p><strong>FileReader<\/strong><br \/>\nIt is used to read two bytes at a time from the source. The function Object() { [native code] } for creating an instance of the FileReader class is as follows.<\/p>\n<p><strong>Syntax of FileReader:<\/strong><\/p>\n<pre><code>FileFileWriter in = new FileWriter(\"path_to_file\");<\/code><\/pre>\n<\/li>\n<li>\n<p><strong>FileWriter<\/strong><br \/>\nIt is used to write two bytes at a time to the destination. The function Object() { [native code] } for creating an instance of the FileWriter class is as follows.<\/p>\n<p><strong>Syntax of FileWriter:<\/strong><\/p>\n<pre><code>FileWriter in = new FileWriter(\"path_to_file\");<\/code><\/pre>\n<p><strong>Example of Character Java Stream:<\/strong><br \/>\nBelow we have the code implementation and explanation <\/p>\n\t\t\t\t\t\t<style>\r\n\t\t\t\t\r\n\t\t\t\t\t#tab_container_14699 {\r\n\toverflow:hidden;\r\n\tdisplay:block;\r\n\twidth:100%;\r\n\tborder:0px solid #ddd;\r\n\tmargin-bottom:30px;\r\n\t}\r\n\r\n#tab_container_14699 .tab-content{\r\n\tpadding:20px;\r\n\tborder: 1px solid #e6e6e6 !important;\r\n\tmargin-top: 0px;\r\n\tbackground-color:#ffffff !important;\r\n\tcolor: #000000 !important;\r\n\tfont-size:16px !important;\r\n\tfont-family: Open Sans !important;\r\n\t\r\n\t\tborder: 1px solid #e6e6e6 !important;\r\n\t}\r\n#tab_container_14699 .wpsm_nav-tabs {\r\n    border-bottom: 0px solid #ddd;\r\n}\r\n#tab_container_14699 .wpsm_nav-tabs > li.active > a, #tab_container_14699 .wpsm_nav-tabs > li.active > a:hover, #tab_container_14699 .wpsm_nav-tabs > li.active > a:focus {\r\n\tcolor: #000000 !important;\r\n\tcursor: default;\r\n\tbackground-color: #ffffff !important;\r\n\tborder: 1px solid #e6e6e6 !important;\r\n}\r\n\r\n#tab_container_14699 .wpsm_nav-tabs > li > a {\r\n    margin-right: 0px !important; \r\n    line-height: 1.42857143 !important;\r\n    border: 1px solid #d5d5d5 !important;\r\n    border-radius: 0px 0px 0 0 !important; \r\n\tbackground-color: #e8e8e8 !important;\r\n\tcolor: #000000 !important;\r\n\tpadding: 15px 18px 15px 18px !important;\r\n\ttext-decoration: none !important;\r\n\tfont-size: 14px !important;\r\n\ttext-align:center !important;\r\n\tfont-family: Open Sans !important;\r\n}\r\n#tab_container_14699 .wpsm_nav-tabs > li > a:focus {\r\noutline: 0px !important;\r\n}\r\n\r\n#tab_container_14699 .wpsm_nav-tabs > li > a:before {\r\n\tdisplay:none !important;\r\n}\r\n#tab_container_14699 .wpsm_nav-tabs > li > a:after {\r\n\tdisplay:none !important ;\r\n}\r\n#tab_container_14699 .wpsm_nav-tabs > li{\r\npadding:0px !important ;\r\nmargin:0px;\r\n}\r\n\r\n#tab_container_14699 .wpsm_nav-tabs > li > a:hover , #tab_container_14699 .wpsm_nav-tabs > li > a:focus {\r\n    color: #000000 !important;\r\n    background-color: #e8e8e8 !important;\r\n\tborder: 1px solid #d5d5d5 !important;\r\n\t\r\n}\r\n#tab_container_14699 .wpsm_nav-tabs > li > a .fa{\r\n\r\nmargin-right:5px !important;\r\n\r\nmargin-left:5px !important;\r\n\r\n\r\n}\r\n\r\n\t\t#tab_container_14699 .wpsm_nav-tabs a{\r\n\t\t\tbackground-image: none;\r\n\t\t\tbackground-position: 0 0;\r\n\t\t\tbackground-repeat: repeat-x;\r\n\t\t}\r\n\t\t\t\r\n\r\n\r\n#tab_container_14699 .wpsm_nav-tabs > li {\r\n    float: left;\r\n    margin-bottom: -1px !important;\r\n\tmargin-right:0px !important; \r\n}\r\n\r\n\r\n#tab_container_14699 .tab-content{\r\noverflow:hidden !important;\r\n}\r\n\r\n\r\n@media (min-width: 769px) {\r\n\r\n\t#tab_container_14699 .wpsm_nav-tabs > li{\r\n\t\tfloat:left !important ;\r\n\t\t\t\tmargin-right:-1px !important;\r\n\t\t\t\t\t}\r\n\t#tab_container_14699 .wpsm_nav-tabs{\r\n\t\tfloat:none !important;\r\n\t\tmargin:0px !important;\r\n\t}\r\n\r\n\t#tab_container_14699 .wpsm_nav-tabs > li {\r\n\t\t\t\t\r\n\t}\r\n\t#tab_container_14699 .wpsm_nav{\r\n\t\t\t}\r\n\r\n}\r\n\r\n\r\n\r\n@media (max-width: 768px) {\r\n\t#tab_container_14699 .wpsm_nav-tabs > li {\r\n\t\t\t\t\r\n\t}\r\n\t#tab_container_14699 .wpsm_nav{\r\n\t\t\t}\r\n}\r\n\r\n\r\n\t.wpsm_nav-tabs li:before{\r\n\t\tdisplay:none !important;\r\n\t}\r\n\r\n\t@media (max-width: 768px) {\r\n\t\t\t\t\r\n\t\t\t\t.wpsm_nav-tabs{\r\n\t\t\tmargin-left:0px !important;\r\n\t\t\tmargin-right:0px !important; \r\n\t\t\t\r\n\t\t}\r\n\t\t\t\t#tab_container_14699 .wpsm_nav-tabs > li{\r\n\t\t\tfloat:none !important;\r\n\t\t}\r\n\t\t\t\r\n\t}\t\t\t\t<\/style>\r\n\t\t\t\t<div id=\"tab_container_14699\" >\r\n\t \r\n\t\t\t\t\t<ul class=\"wpsm_nav wpsm_nav-tabs\" role=\"tablist\" id=\"myTab_14699\">\r\n\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t<li role=\"presentation\"  class=\"active\"  onclick=\"do_resize()\">\r\n\t\t\t\t\t\t\t\t<a href=\"#tabs_desc_14699_1\" aria-controls=\"tabs_desc_14699_1\" role=\"tab\" data-toggle=\"tab\">\r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<i class=\"fa fa-code\"><\/i> \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t<span>java<\/span>\r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t<\/a>\r\n\t\t\t\t\t\t\t<\/li>\r\n\t\t\t\t\t\t\t\t\t\t\t <\/ul>\r\n\r\n\t\t\t\t\t  <!-- Tab panes -->\r\n\t\t\t\t\t  <div class=\"tab-content\" id=\"tab-content_14699\">\r\n\t\t\t\t\t\t\t\t\t\t\t\t <div role=\"tabpanel\" class=\"tab-pane  in active \" id=\"tabs_desc_14699_1\">\r\n\t\t\t\t\t\t\t\t<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"java\">import java.io.*;\r\npublic class CharacterStreamExample {\r\n\r\n   public static void main(String args[]) throws IOException {\r\n      FileReader in = null;\r\n      FileWriter out = null;\r\n\r\n       \/\/ Reading source file using read method \r\n        \/\/ and write to file using write method\r\n      try {\r\n         in = new FileReader(\"source.txt\");\r\n         out = new FileWriter(\"destination.txt\");\r\n         int c;\r\n         while ((c = in.read()) != -1) {\r\n            out.write(c);\r\n         }\r\n      }\r\n       finally {\r\n         if (in != null) {\r\n            in.close();\r\n         }\r\n         if (out != null) {\r\n            out.close();\r\n         }\r\n      }\r\n   }\r\n}\r\n<\/pre>\t\t\t\t\t\t <\/div>\r\n\t\t\t\t\t\t\t\r\n\t\t\t\t\t <\/div>\r\n\t\t\t\t\t \r\n\t\t\t\t <\/div>\r\n <script>\r\n\t\tjQuery(function () {\r\n\t\t\tjQuery('#myTab_14699 a:first').tab('show')\r\n\t\t});\r\n\t\t\r\n\t\t\t\tjQuery(function(){\r\n\t\t\tvar b=\"fadeIn\";\r\n\t\t\tvar c;\r\n\t\t\tvar a;\r\n\t\t\td(jQuery(\"#myTab_14699 a\"),jQuery(\"#tab-content_14699\"));function d(e,f,g){\r\n\t\t\t\te.click(function(i){\r\n\t\t\t\t\ti.preventDefault();\r\n\t\t\t\t\tjQuery(this).tab(\"show\");\r\n\t\t\t\t\tvar h=jQuery(this).data(\"easein\");\r\n\t\t\t\t\tif(c){c.removeClass(a);}\r\n\t\t\t\t\tif(h){f.find(\"div.active\").addClass(\"animated \"+h);a=h;}\r\n\t\t\t\t\telse{if(g){f.find(\"div.active\").addClass(\"animated \"+g);a=g;}else{f.find(\"div.active\").addClass(\"animated \"+b);a=b;}}c=f.find(\"div.active\");\r\n\t\t\t\t});\r\n\t\t\t}\r\n\t\t});\r\n\t\t\r\n\r\n\t\tfunction do_resize(){\r\n\r\n\t\t\tvar width=jQuery( '.tab-content .tab-pane iframe' ).width();\r\n\t\t\tvar height=jQuery( '.tab-content .tab-pane iframe' ).height();\r\n\r\n\t\t\tvar toggleSize = true;\r\n\t\t\tjQuery('iframe').animate({\r\n\t\t\t    width: toggleSize ? width : 640,\r\n\t\t\t    height: toggleSize ? height : 360\r\n\t\t\t  }, 250);\r\n\r\n\t\t\t  toggleSize = !toggleSize;\r\n\t\t}\r\n\r\n\r\n\t<\/script>\r\n\t\t\t\t\r\n\t\t\t\n<p><strong>Output:<\/strong><\/p>\n<pre><code>Hello from prepbytes ,this is  about character stream.<\/code><\/pre>\n<p><strong>Explanation<\/strong><br \/>\nThis example uses Character Stream to copy the contents of one file to another. In the following example, we will create two FileReader and FileWriter objects. The names of the source and destination files are passed as parameters to the FileReader and FileWriter classes, respectively. The source file&#8217;s content is then copied to the destination file. Assume we&#8217;ve already created a file called source.txt with the following contents when we run the preceding program, it will generate a file called destination.txt with the same contents as source.txt. An exception of FileAlreadyExistsException is thrown if a file with the same name already exists.<\/p>\n<\/li>\n<\/ul>\n<h3>Difference between Byte Stream and Character Stream:<\/h3>\n<p>Here we have the differences:<\/p>\n<table>\n<thead>\n<tr>\n<th>Byte Stream<\/th>\n<th>Character Stream<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>It operates on raw binary data and data is processed byte by byte<\/td>\n<td>It operates on text data and is processed character by character<\/td>\n<\/tr>\n<tr>\n<td>Suitable for processing non-textual data such as images, videos, etc.<\/td>\n<td>Suitable for processing textual data such as documents, HTML, etc.<\/td>\n<\/tr>\n<tr>\n<td>Input and Output operations are performed using InputStream and OutputStream classes<\/td>\n<td>Input and Output operations are performed using Reader and Writer classes<\/td>\n<\/tr>\n<tr>\n<td>Suitable for low-level input and output operations<\/td>\n<td>Suitable for high-level input and output operations<\/td>\n<\/tr>\n<tr>\n<td>Examples include FileInputStream and FileOutputStream<\/td>\n<td>Examples include FileReader and FileWriter<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><strong>Conclusion<\/strong><br \/>\nThe java stream method aids in sequentially accessing a file. There are two types of java streams: Byte Stream and Character Stream. Byte streams are used to perform input and output of 8-bit bytes. When we want to read\/write binary data, we can use byte streams. The character stream is used to perform 16-bit Unicode input and output operations. Character streams are used to read and write characters. Byte and Character Streams have a three-phase mechanism that includes Split, Apply, and Combine.FileInputStream and FileOutputStream are common classes for reading and writing data using byte streams.FileReader and FileWriter are commonly used to read and write data using character streams.<\/p>\n<h2>Frequently Asked Questions(FAQ)<\/h2>\n<p>Here are the FAQs on the java stream <\/p>\n<p><strong>Q1: What are InputStream and OutputStream classes in Java?<\/strong><br \/>\n<strong>A:<\/strong> InputStream and OutputStream are abstract classes in Java that represent the input and output streams of bytes. They provide methods for reading and writing bytes from and to a source.<\/p>\n<p><strong>Q2: What are Reader and Writer classes in Java?<\/strong><br \/>\n<strong>A:<\/strong> Reader and Writer are abstract classes in Java that represent the input and output streams of characters. They provide methods for reading and writing characters from and to a source.<\/p>\n<p><strong>Q3: What is the difference between InputStream\/OutputStream and Reader\/Writer classes?<\/strong><br \/>\n<strong>A:<\/strong> InputStream\/OutputStream classes operate on raw binary data, while Reader\/Writer classes operate on text data. InputStream\/OutputStream classes process data byte by byte, while Reader\/Writer classes process data character by character. InputStream\/OutputStream classes do not perform any character encoding or decoding, while Reader\/Writer classes perform character encoding and decoding using specified character sets.<\/p>\n<p><strong>Q4: What are some examples of Byte Stream classes in Java?<\/strong><br \/>\n<strong>A:<\/strong> Some examples of Byte Stream classes in Java include FileInputStream, FileOutputStream, BufferedInputStream, and BufferedOutputStream.<\/p>\n<p><strong>Q5: What are some examples of Character Stream classes in Java?<\/strong><br \/>\n<strong>A:<\/strong> Some examples of Character Stream classes in Java include FileReader, FileWriter, BufferedReader, and BufferedWriter.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Streams are a powerful feature introduced in Java 8 that revolutionized the way we work with collections and data manipulation. Streams provide a concise and functional way to perform operations on data, making code more readable, maintainable, and efficient. Whether you&#8217;re dealing with lists, arrays, or any collection, streams offer a modern approach to transform, [&hellip;]<\/p>\n","protected":false},"author":52,"featured_media":0,"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":[143],"tags":[],"class_list":["post-14768","post","type-post","status-publish","format-standard","hentry","category-java"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v25.8 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Streams in Java<\/title>\n<meta name=\"description\" content=\"Know different Types of Streams in Java in detail and difference between Byte Stream and Character Stream.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/prepbytes.com\/blog\/streams-in-java\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Streams in Java\" \/>\n<meta property=\"og:description\" content=\"Know different Types of Streams in Java in detail and difference between Byte Stream and Character Stream.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/prepbytes.com\/blog\/streams-in-java\/\" \/>\n<meta property=\"og:site_name\" content=\"PrepBytes Blog\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/prepbytes0211\/\" \/>\n<meta property=\"article:published_time\" content=\"2023-03-22T10:29:03+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-08-17T12:39:46+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1679404599043-Streams%20in%20Java.jpg\" \/>\n<meta name=\"author\" content=\"Prepbytes\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Prepbytes\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/prepbytes.com\/blog\/streams-in-java\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/streams-in-java\/\"},\"author\":{\"name\":\"Prepbytes\",\"@id\":\"http:\/\/43.205.93.38\/#\/schema\/person\/3f7dc4ae851791d5947a7f99df363d5e\"},\"headline\":\"Streams in Java\",\"datePublished\":\"2023-03-22T10:29:03+00:00\",\"dateModified\":\"2023-08-17T12:39:46+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/streams-in-java\/\"},\"wordCount\":1329,\"commentCount\":0,\"publisher\":{\"@id\":\"http:\/\/43.205.93.38\/#organization\"},\"image\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/streams-in-java\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1679404599043-Streams%20in%20Java.jpg\",\"articleSection\":[\"Java\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/prepbytes.com\/blog\/streams-in-java\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/prepbytes.com\/blog\/streams-in-java\/\",\"url\":\"https:\/\/prepbytes.com\/blog\/streams-in-java\/\",\"name\":\"Streams in Java\",\"isPartOf\":{\"@id\":\"http:\/\/43.205.93.38\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/streams-in-java\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/streams-in-java\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1679404599043-Streams%20in%20Java.jpg\",\"datePublished\":\"2023-03-22T10:29:03+00:00\",\"dateModified\":\"2023-08-17T12:39:46+00:00\",\"description\":\"Know different Types of Streams in Java in detail and difference between Byte Stream and Character Stream.\",\"breadcrumb\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/streams-in-java\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/prepbytes.com\/blog\/streams-in-java\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/prepbytes.com\/blog\/streams-in-java\/#primaryimage\",\"url\":\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1679404599043-Streams%20in%20Java.jpg\",\"contentUrl\":\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1679404599043-Streams%20in%20Java.jpg\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/prepbytes.com\/blog\/streams-in-java\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"http:\/\/43.205.93.38\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Java\",\"item\":\"https:\/\/prepbytes.com\/blog\/category\/java\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Streams in Java\"}]},{\"@type\":\"WebSite\",\"@id\":\"http:\/\/43.205.93.38\/#website\",\"url\":\"http:\/\/43.205.93.38\/\",\"name\":\"PrepBytes Blog\",\"description\":\"ONE-STOP RESOURCE FOR EVERYTHING RELATED TO CODING\",\"publisher\":{\"@id\":\"http:\/\/43.205.93.38\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"http:\/\/43.205.93.38\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"http:\/\/43.205.93.38\/#organization\",\"name\":\"Prepbytes\",\"url\":\"http:\/\/43.205.93.38\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"http:\/\/43.205.93.38\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/blog.prepbytes.com\/wp-content\/uploads\/2025\/07\/uzxxllgloialmn9mhwfe.webp\",\"contentUrl\":\"https:\/\/blog.prepbytes.com\/wp-content\/uploads\/2025\/07\/uzxxllgloialmn9mhwfe.webp\",\"width\":160,\"height\":160,\"caption\":\"Prepbytes\"},\"image\":{\"@id\":\"http:\/\/43.205.93.38\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/prepbytes0211\/\",\"https:\/\/www.instagram.com\/prepbytes\/\",\"https:\/\/www.linkedin.com\/company\/prepbytes\/\",\"https:\/\/www.youtube.com\/channel\/UC0xGnHDrjUM1pDEK2Ka5imA\"]},{\"@type\":\"Person\",\"@id\":\"http:\/\/43.205.93.38\/#\/schema\/person\/3f7dc4ae851791d5947a7f99df363d5e\",\"name\":\"Prepbytes\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"http:\/\/43.205.93.38\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/232042cd1a1ea0e982c96d2a2ec93fb70a8e864e00784491231e7bfe5a9e06b5?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/232042cd1a1ea0e982c96d2a2ec93fb70a8e864e00784491231e7bfe5a9e06b5?s=96&d=mm&r=g\",\"caption\":\"Prepbytes\"},\"url\":\"https:\/\/prepbytes.com\/blog\/author\/gourav-jaincollegedekho-com\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Streams in Java","description":"Know different Types of Streams in Java in detail and difference between Byte Stream and Character Stream.","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:\/\/prepbytes.com\/blog\/streams-in-java\/","og_locale":"en_US","og_type":"article","og_title":"Streams in Java","og_description":"Know different Types of Streams in Java in detail and difference between Byte Stream and Character Stream.","og_url":"https:\/\/prepbytes.com\/blog\/streams-in-java\/","og_site_name":"PrepBytes Blog","article_publisher":"https:\/\/www.facebook.com\/prepbytes0211\/","article_published_time":"2023-03-22T10:29:03+00:00","article_modified_time":"2023-08-17T12:39:46+00:00","og_image":[{"url":"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1679404599043-Streams%20in%20Java.jpg","type":"","width":"","height":""}],"author":"Prepbytes","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Prepbytes","Est. reading time":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/prepbytes.com\/blog\/streams-in-java\/#article","isPartOf":{"@id":"https:\/\/prepbytes.com\/blog\/streams-in-java\/"},"author":{"name":"Prepbytes","@id":"http:\/\/43.205.93.38\/#\/schema\/person\/3f7dc4ae851791d5947a7f99df363d5e"},"headline":"Streams in Java","datePublished":"2023-03-22T10:29:03+00:00","dateModified":"2023-08-17T12:39:46+00:00","mainEntityOfPage":{"@id":"https:\/\/prepbytes.com\/blog\/streams-in-java\/"},"wordCount":1329,"commentCount":0,"publisher":{"@id":"http:\/\/43.205.93.38\/#organization"},"image":{"@id":"https:\/\/prepbytes.com\/blog\/streams-in-java\/#primaryimage"},"thumbnailUrl":"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1679404599043-Streams%20in%20Java.jpg","articleSection":["Java"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/prepbytes.com\/blog\/streams-in-java\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/prepbytes.com\/blog\/streams-in-java\/","url":"https:\/\/prepbytes.com\/blog\/streams-in-java\/","name":"Streams in Java","isPartOf":{"@id":"http:\/\/43.205.93.38\/#website"},"primaryImageOfPage":{"@id":"https:\/\/prepbytes.com\/blog\/streams-in-java\/#primaryimage"},"image":{"@id":"https:\/\/prepbytes.com\/blog\/streams-in-java\/#primaryimage"},"thumbnailUrl":"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1679404599043-Streams%20in%20Java.jpg","datePublished":"2023-03-22T10:29:03+00:00","dateModified":"2023-08-17T12:39:46+00:00","description":"Know different Types of Streams in Java in detail and difference between Byte Stream and Character Stream.","breadcrumb":{"@id":"https:\/\/prepbytes.com\/blog\/streams-in-java\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/prepbytes.com\/blog\/streams-in-java\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/prepbytes.com\/blog\/streams-in-java\/#primaryimage","url":"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1679404599043-Streams%20in%20Java.jpg","contentUrl":"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1679404599043-Streams%20in%20Java.jpg"},{"@type":"BreadcrumbList","@id":"https:\/\/prepbytes.com\/blog\/streams-in-java\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"http:\/\/43.205.93.38\/"},{"@type":"ListItem","position":2,"name":"Java","item":"https:\/\/prepbytes.com\/blog\/category\/java\/"},{"@type":"ListItem","position":3,"name":"Streams in Java"}]},{"@type":"WebSite","@id":"http:\/\/43.205.93.38\/#website","url":"http:\/\/43.205.93.38\/","name":"PrepBytes Blog","description":"ONE-STOP RESOURCE FOR EVERYTHING RELATED TO CODING","publisher":{"@id":"http:\/\/43.205.93.38\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"http:\/\/43.205.93.38\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"http:\/\/43.205.93.38\/#organization","name":"Prepbytes","url":"http:\/\/43.205.93.38\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"http:\/\/43.205.93.38\/#\/schema\/logo\/image\/","url":"https:\/\/blog.prepbytes.com\/wp-content\/uploads\/2025\/07\/uzxxllgloialmn9mhwfe.webp","contentUrl":"https:\/\/blog.prepbytes.com\/wp-content\/uploads\/2025\/07\/uzxxllgloialmn9mhwfe.webp","width":160,"height":160,"caption":"Prepbytes"},"image":{"@id":"http:\/\/43.205.93.38\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/prepbytes0211\/","https:\/\/www.instagram.com\/prepbytes\/","https:\/\/www.linkedin.com\/company\/prepbytes\/","https:\/\/www.youtube.com\/channel\/UC0xGnHDrjUM1pDEK2Ka5imA"]},{"@type":"Person","@id":"http:\/\/43.205.93.38\/#\/schema\/person\/3f7dc4ae851791d5947a7f99df363d5e","name":"Prepbytes","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"http:\/\/43.205.93.38\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/232042cd1a1ea0e982c96d2a2ec93fb70a8e864e00784491231e7bfe5a9e06b5?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/232042cd1a1ea0e982c96d2a2ec93fb70a8e864e00784491231e7bfe5a9e06b5?s=96&d=mm&r=g","caption":"Prepbytes"},"url":"https:\/\/prepbytes.com\/blog\/author\/gourav-jaincollegedekho-com\/"}]}},"_links":{"self":[{"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/posts\/14768","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/users\/52"}],"replies":[{"embeddable":true,"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/comments?post=14768"}],"version-history":[{"count":2,"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/posts\/14768\/revisions"}],"predecessor-version":[{"id":17651,"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/posts\/14768\/revisions\/17651"}],"wp:attachment":[{"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/media?parent=14768"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/categories?post=14768"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/tags?post=14768"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}