{"id":22228,"date":"2017-01-11T03:05:23","date_gmt":"2017-01-11T03:05:23","guid":{"rendered":"https:\/\/www.testingdocs.com\/questions\/?p=22228"},"modified":"2024-12-14T04:27:11","modified_gmt":"2024-12-14T04:27:11","slug":"difference-between-read-and-readline-methods-in-java","status":"publish","type":"post","link":"https:\/\/www.testingdocs.com\/questions\/difference-between-read-and-readline-methods-in-java\/","title":{"rendered":"Difference between read() and readline() methods in Java"},"content":{"rendered":"<h2>Difference between read() and readline() methods in Java<\/h2>\n<p>Let&#8217;s see the differences between read() and readline() methods in Java programming language.<\/p>\n<h2>read() vs readline()<\/h2>\n<p>The difference between the read() and readline() methods are as follows:<\/p>\n<table border=\"1\" cellspacing=\"1\" cellpadding=\"1\">\n<tbody>\n<tr>\n<td style=\"text-align: center;\"><strong>SNo.<\/strong><\/td>\n<td style=\"text-align: center;\"><strong>read()\u00a0\u00a0<\/strong><\/td>\n<td style=\"text-align: center;\"><strong>readline()\u00a0<\/strong><\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;\">1.<\/td>\n<td>read() is suitable for reading one byte( single character)<\/td>\n<td>readline() is suitable to read a group of characters at a time.<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;\">2.<\/td>\n<td>read() method supports 8-bit ASCII format only. It is suitable for standalone applications.<\/td>\n<td>readline() supports 16-bit UNI code format. It is suitable for web applications.<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;\">3.<\/td>\n<td>read() method always returns an int value.<\/td>\n<td>readline() method returns String value.<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;\">4.<\/td>\n<td>read() method can be applied to any stream.<\/td>\n<td>readline() is only suitable for BufferedReader.<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;\">5.<\/td>\n<td>read() can be terminated whenever a negative number is encountered.<\/td>\n<td>readline() can be terminated whenever <em>null, \/n\u00a0<\/em> is encountered.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Difference between read() and readline() methods in Java Let&#8217;s see the differences between read() and readline() methods in Java programming language. read() vs readline() The difference between the read() and readline() methods are as follows: SNo. read()\u00a0\u00a0 readline()\u00a0 1. read() is suitable for reading one byte( single character) readline() is suitable to read a group [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[40],"tags":[],"class_list":["post-22228","post","type-post","status-publish","format-standard","hentry","category-java","has-post-title","has-post-date","has-post-category","has-post-tag","has-post-comment","has-post-author",""],"_links":{"self":[{"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/posts\/22228","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/comments?post=22228"}],"version-history":[{"count":6,"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/posts\/22228\/revisions"}],"predecessor-version":[{"id":26410,"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/posts\/22228\/revisions\/26410"}],"wp:attachment":[{"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/media?parent=22228"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/categories?post=22228"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/tags?post=22228"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}