{"id":89769,"date":"2024-12-09T18:00:56","date_gmt":"2024-12-09T12:30:56","guid":{"rendered":"https:\/\/techvidvan.com\/tutorials\/?p=89769"},"modified":"2024-12-09T18:53:40","modified_gmt":"2024-12-09T13:23:40","slug":"java-filterinputstream-class","status":"publish","type":"post","link":"https:\/\/techvidvan.com\/tutorials\/java-filterinputstream-class\/","title":{"rendered":"Java FilterInputStream Class"},"content":{"rendered":"<p>The InputStream is implemented by the Java FilterInputStream class. To provide extra functionality, it has various subclasses like DataInputStream and BufferedInputStream. So, its individual use is declining.<\/p>\n<h2>Explanation<\/h2>\n<p>The Java FilterInputStream class functions similarly to the Java InputStream class; however, it merely overrides the InputStream class methods and passes the request to the InputStream.<\/p>\n<p>The FilterInputStream Class&#8217;s read() method filters, reads and forwards the data to the underlying stream filtering, which the Streams carry out.<\/p>\n<p><strong>Syntax<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">public class FilterInputStream extends Inputstream<\/pre>\n<h3>Constructor<\/h3>\n<p>protected FilterInputStream(InputStream in): assigns the argument to the field this.in to create a FilterInputStream and stores it for later use.<\/p>\n<h3>Methods<\/h3>\n<table>\n<tbody>\n<tr>\n<td><strong>Method\u00a0<\/strong><\/td>\n<td><strong>Description\u00a0<\/strong><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">int available()<\/span><\/td>\n<td><span style=\"font-weight: 400;\">It provides a ballpark estimate of the data that can be read from the input stream.<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">int read()<\/span><\/td>\n<td><span style=\"font-weight: 400;\">It reads the subsequent data byte from the input stream.<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">int read(byte[] b)<\/span><\/td>\n<td><span style=\"font-weight: 400;\">It reads data from the input stream up to byte.length bytes in length.<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">long skip(long n)<\/span><\/td>\n<td><span style=\"font-weight: 400;\">It aims to remove and skip n bytes of data from the input stream.<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">boolean markSupported()<\/span><\/td>\n<td><span style=\"font-weight: 400;\">It checks whether the input stream supports the mark and reset methods.<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">void mark(int readlimit)<\/span><\/td>\n<td><span style=\"font-weight: 400;\">It serves as a marker for the input stream&#8217;s current position.<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">void reset()<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Resetting the input stream is done with it.<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">Void close()<\/span><\/td>\n<td><span style=\"font-weight: 400;\">The input stream is closed using it.<\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4>Example<\/h4>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">import java.io.*;  \r\npublic class TechVidvan{  \r\n    public static void main(String[] args) throws IOException {  \r\n        File data = new File(\"D:\\\\testout.txt\");  \r\n        FileInputStream  file = new FileInputStream(data);  \r\n        FilterInputStream filter = new BufferedInputStream(file);  \r\n        int k =0;  \r\n        while((k=filter.read())!=-1){  \r\n            System.out.print((char)k);  \r\n        }  \r\n        file.close();  \r\n        filter.close();  \r\n    }  \r\n}<\/pre>\n<p><strong>Output<\/strong><br \/>\nJava programming in TechVidvan<\/p>\n<h4>Example<\/h4>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">import java.io.BufferedInputStream;\r\nimport java.io.FileInputStream;\r\nimport java.io.FilterInputStream;\r\nimport java.io.IOException;\r\npublic class TechVidvan {\r\npublic static void main(String[ ] args) throws IOException\r\n{\r\n String filepath = \"D:\\\\myfile.txt\";\t\r\n FileInputStream  fis = new FileInputStream(filepath);  \r\n FilterInputStream filter = new BufferedInputStream(fis);  \r\n  \r\n int availableBytes = filter.available();\r\n System.out.println(\"Initial bytes: \" +available);\r\n \r\n filter.read();\r\n filter.read();\r\n filter.read();\r\n \r\n int available = filter.available();\r\n System.out.println(\"after reading 3bytes: \" +available);\r\n filter.close();  \r\n }\r\n}<\/pre>\n<p><strong>Output<\/strong><br \/>\n<strong>Initial bytes:<\/strong> 25<br \/>\n<strong>after reading 3bytes:<\/strong> 22<\/p>\n<h4>Example<\/h4>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">import java.io.BufferedInputStream;\r\nimport java.io.File;\r\nimport java.io.FileInputStream;\r\nimport java.io.FilterInputStream;\r\nimport java.io.IOException;\r\npublic class StudyTonight \r\n{\r\n  public static void main(String[] args) throws IOException \r\n  { \r\n    File data = new File(\"E:\\\\studytonight\\\\output.txt\");  \r\n    FileInputStream  file = new FileInputStream(data);  \r\n    FilterInputStream filter = new BufferedInputStream(file);  \r\n    int ch =0;  \r\n    while((ch=filter.read())!=-1){  \r\n      System.out.println(filter.available());  \r\n    }  \r\n    file.close();  \r\n    filter.close();   \r\n  }  \r\n}<\/pre>\n<p><strong>Output<\/strong><\/p>\n<p>5<br \/>\n4<br \/>\n3<br \/>\n2<br \/>\n1<br \/>\n0<br \/>\nJava<\/p>\n<h3>Conclusion<\/h3>\n<p>The superclass of the input operation, the input stream, is used to read user input from a file, keyboard, etc. It is employed to depict a byte-stream input. It skips n bytes of data from the input stream and discards it.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The InputStream is implemented by the Java FilterInputStream class. To provide extra functionality, it has various subclasses like DataInputStream and BufferedInputStream. So, its individual use is declining. Explanation The Java FilterInputStream class functions similarly&#46;&#46;&#46;<\/p>\n","protected":false},"author":6,"featured_media":447238,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[183],"tags":[5520,295,296,298,5686,299,263,250],"class_list":["post-89769","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-java","tag-filterinputstream-class","tag-filterinputstream-class-in-java","tag-java","tag-java-filterinputstream-class","tag-java-filterinputstream-class-with-examples","tag-java-tutorial","tag-java-tutorial-for-beginners","tag-learn-java"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.7 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Java FilterInputStream Class - TechVidvan<\/title>\n<meta name=\"description\" content=\"The FilterInputStream Class&#039;s read() method filters, reads and forwards the data to the underlying stream filtering, which the Streams carry out.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/techvidvan.com\/tutorials\/java-filterinputstream-class\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Java FilterInputStream Class - TechVidvan\" \/>\n<meta property=\"og:description\" content=\"The FilterInputStream Class&#039;s read() method filters, reads and forwards the data to the underlying stream filtering, which the Streams carry out.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/techvidvan.com\/tutorials\/java-filterinputstream-class\/\" \/>\n<meta property=\"og:site_name\" content=\"TechVidvan\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/TechVidvan\/\" \/>\n<meta property=\"article:published_time\" content=\"2024-12-09T12:30:56+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-12-09T13:23:40+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2024\/06\/java-filterinputstream.webp\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"628\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/webp\" \/>\n<meta name=\"author\" content=\"TechVidvan Team\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@vidvantech\" \/>\n<meta name=\"twitter:site\" content=\"@vidvantech\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"TechVidvan Team\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Java FilterInputStream Class - TechVidvan","description":"The FilterInputStream Class's read() method filters, reads and forwards the data to the underlying stream filtering, which the Streams carry out.","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:\/\/techvidvan.com\/tutorials\/java-filterinputstream-class\/","og_locale":"en_US","og_type":"article","og_title":"Java FilterInputStream Class - TechVidvan","og_description":"The FilterInputStream Class's read() method filters, reads and forwards the data to the underlying stream filtering, which the Streams carry out.","og_url":"https:\/\/techvidvan.com\/tutorials\/java-filterinputstream-class\/","og_site_name":"TechVidvan","article_publisher":"https:\/\/www.facebook.com\/TechVidvan\/","article_published_time":"2024-12-09T12:30:56+00:00","article_modified_time":"2024-12-09T13:23:40+00:00","og_image":[{"width":1200,"height":628,"url":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2024\/06\/java-filterinputstream.webp","type":"image\/webp"}],"author":"TechVidvan Team","twitter_card":"summary_large_image","twitter_creator":"@vidvantech","twitter_site":"@vidvantech","twitter_misc":{"Written by":"TechVidvan Team","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/techvidvan.com\/tutorials\/java-filterinputstream-class\/#article","isPartOf":{"@id":"https:\/\/techvidvan.com\/tutorials\/java-filterinputstream-class\/"},"author":{"name":"TechVidvan Team","@id":"https:\/\/techvidvan.com\/tutorials\/#\/schema\/person\/dde481bb412350cde1ed6e389bc0deaf"},"headline":"Java FilterInputStream Class","datePublished":"2024-12-09T12:30:56+00:00","dateModified":"2024-12-09T13:23:40+00:00","mainEntityOfPage":{"@id":"https:\/\/techvidvan.com\/tutorials\/java-filterinputstream-class\/"},"wordCount":279,"commentCount":0,"publisher":{"@id":"https:\/\/techvidvan.com\/tutorials\/#organization"},"image":{"@id":"https:\/\/techvidvan.com\/tutorials\/java-filterinputstream-class\/#primaryimage"},"thumbnailUrl":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2024\/06\/java-filterinputstream.webp","keywords":["filterinputstream class","filterInputStream class in java","java","java filterInputStream class","java filterinputstream class with examples","Java Tutorial","java tutorial for beginners","Learn Java"],"articleSection":["Java Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/techvidvan.com\/tutorials\/java-filterinputstream-class\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/techvidvan.com\/tutorials\/java-filterinputstream-class\/","url":"https:\/\/techvidvan.com\/tutorials\/java-filterinputstream-class\/","name":"Java FilterInputStream Class - TechVidvan","isPartOf":{"@id":"https:\/\/techvidvan.com\/tutorials\/#website"},"primaryImageOfPage":{"@id":"https:\/\/techvidvan.com\/tutorials\/java-filterinputstream-class\/#primaryimage"},"image":{"@id":"https:\/\/techvidvan.com\/tutorials\/java-filterinputstream-class\/#primaryimage"},"thumbnailUrl":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2024\/06\/java-filterinputstream.webp","datePublished":"2024-12-09T12:30:56+00:00","dateModified":"2024-12-09T13:23:40+00:00","description":"The FilterInputStream Class's read() method filters, reads and forwards the data to the underlying stream filtering, which the Streams carry out.","breadcrumb":{"@id":"https:\/\/techvidvan.com\/tutorials\/java-filterinputstream-class\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/techvidvan.com\/tutorials\/java-filterinputstream-class\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/techvidvan.com\/tutorials\/java-filterinputstream-class\/#primaryimage","url":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2024\/06\/java-filterinputstream.webp","contentUrl":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2024\/06\/java-filterinputstream.webp","width":1200,"height":628,"caption":"java filterinputstream"},{"@type":"BreadcrumbList","@id":"https:\/\/techvidvan.com\/tutorials\/java-filterinputstream-class\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/techvidvan.com\/tutorials\/"},{"@type":"ListItem","position":2,"name":"Java FilterInputStream Class"}]},{"@type":"WebSite","@id":"https:\/\/techvidvan.com\/tutorials\/#website","url":"https:\/\/techvidvan.com\/tutorials\/","name":"TechVidvan Blogs","description":"","publisher":{"@id":"https:\/\/techvidvan.com\/tutorials\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/techvidvan.com\/tutorials\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/techvidvan.com\/tutorials\/#organization","name":"TechVidvan","url":"https:\/\/techvidvan.com\/tutorials\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/techvidvan.com\/tutorials\/#\/schema\/logo\/image\/","url":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2024\/03\/techvidvan-logo-200x50-1.webp","contentUrl":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2024\/03\/techvidvan-logo-200x50-1.webp","width":200,"height":50,"caption":"TechVidvan"},"image":{"@id":"https:\/\/techvidvan.com\/tutorials\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/TechVidvan\/","https:\/\/x.com\/vidvantech"]},{"@type":"Person","@id":"https:\/\/techvidvan.com\/tutorials\/#\/schema\/person\/dde481bb412350cde1ed6e389bc0deaf","name":"TechVidvan Team"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/posts\/89769","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/users\/6"}],"replies":[{"embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/comments?post=89769"}],"version-history":[{"count":3,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/posts\/89769\/revisions"}],"predecessor-version":[{"id":447762,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/posts\/89769\/revisions\/447762"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/media\/447238"}],"wp:attachment":[{"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/media?parent=89769"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/categories?post=89769"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/tags?post=89769"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}