{"id":1282,"date":"2022-02-26T07:43:12","date_gmt":"2022-02-26T07:43:12","guid":{"rendered":"https:\/\/mdr.foobrdigital.com\/?p=1282"},"modified":"2022-02-26T07:43:12","modified_gmt":"2022-02-26T07:43:12","slug":"java-i-o-streams","status":"publish","type":"post","link":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/2022\/02\/26\/java-i-o-streams\/","title":{"rendered":"Java I\/O Streams"},"content":{"rendered":"\n<p>In this tutorial, we will learn about Java input\/output streams and their types.<\/p>\n\n\n\n<p id=\"introduction\">In Java, streams are the sequence of data that are read from the source and written to the destination.<\/p>\n\n\n\n<p>An&nbsp;<strong>input stream<\/strong>&nbsp;is used to read data from the source. And, an&nbsp;<strong>output stream<\/strong>&nbsp;is used to write data to the destination.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>class HelloWorld {\n    public static void main(String&#91;] args) {\n        System.out.println(\"Hello, World!\"); \n    }\n}\n<\/code><\/pre>\n\n\n\n<p>For example, in our first&nbsp;<strong>Hello World<\/strong>&nbsp;example, we have used&nbsp;<code>System.out<\/code>&nbsp;to print a string. Here, the&nbsp;<code>System.out<\/code>&nbsp;is a type of output stream.<\/p>\n\n\n\n<p>Similarly, there are input streams to take input.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/cdn.programiz.com\/sites\/tutorial2program\/files\/java-io-stream.png\" alt=\"Input stream reads data from source to program and output stream writes file from program to destination\" title=\"Java Input Stream and Output Stream\"\/><\/figure>\n\n\n\n<p>We will learn about input streams and output streams in detail in the later tutorials.<\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">Types of Streams<\/h2>\n\n\n\n<p>Depending upon the data a stream holds, it can be classified into:<\/p>\n\n\n\n<ul><li>Byte Stream<\/li><li>Character Stream<\/li><\/ul>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"byte\">Byte Stream<\/h3>\n\n\n\n<p>Byte stream is used to read and write a single byte (8 bits) of data.<\/p>\n\n\n\n<p>All byte stream classes are derived from base abstract classes called&nbsp;<code>InputStream<\/code>&nbsp;and&nbsp;<code>OutputStream<\/code>.<\/p>\n\n\n\n<p>To learn more, visit<\/p>\n\n\n\n<ul><li>Java InputStream Class<\/li><li>Java OutputStream Class<\/li><\/ul>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"character\">Character Stream<\/h3>\n\n\n\n<p>Character stream is used to read and write a single character of data.<\/p>\n\n\n\n<p>All the character stream classes are derived from base abstract classes&nbsp;<code>Reader<\/code>&nbsp;and&nbsp;<code>Writer<\/code>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this tutorial, we will learn about Java input\/output streams and their types. In Java, streams are the sequence of data that are read from the source and written to the destination. An&nbsp;input stream&nbsp;is used to read data from the source. And, an&nbsp;output stream&nbsp;is used to write data to the destination. For example, in our [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[483],"tags":[],"_links":{"self":[{"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/posts\/1282"}],"collection":[{"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/comments?post=1282"}],"version-history":[{"count":0,"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/posts\/1282\/revisions"}],"wp:attachment":[{"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/media?parent=1282"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/categories?post=1282"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/tags?post=1282"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}