

{"id":13717,"date":"2018-04-27T09:12:46","date_gmt":"2018-04-27T09:12:46","guid":{"rendered":"https:\/\/data-flair.training\/blogs\/?p=13717"},"modified":"2026-05-30T16:46:55","modified_gmt":"2026-05-30T11:16:55","slug":"read-java-console-input","status":"publish","type":"post","link":"https:\/\/data-flair.training\/blogs\/read-java-console-input\/","title":{"rendered":"How to Read Java Console Input  | 3 Ways To Read Java Input"},"content":{"rendered":"<p>A programmer cannot always assume what the user wants to input into the program. Most of the time, it is a necessity to make the program interactive. To make the program interactive, the programmer needs to take input from the user. Java provides us with three classes with which we can take console input from the user. In this article, we will discuss all these classes one by one.<\/p>\n<h3>Classes provided by Java to take console Input<\/h3>\n<p><strong>Three classes are using which we can take console input:<\/strong><\/p>\n<ul>\n<li>BufferedReader class<\/li>\n<li>Scanner class<\/li>\n<li>Console class<\/li>\n<\/ul>\n<p><strong>There is also another way to take console input in Java:<\/strong><\/p>\n<p>Using Command Line Argument<\/p>\n<p>Let us discuss each of these classes at length.<\/p>\n<h3>1. Java BufferedReader Class<\/h3>\n<p>The BufferReader class is part of the java.io package. It is the oldest method introduced in Java to take user input. It has been present in Java since the very beginning. The BufferedReader class wraps the System.in(System Input) with the InputStreamReader.<\/p>\n<p>Let us see how BufferedReader objects are called:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">BufferedReader br= new BufferedReader(new InputStreamReader(System.in));\r\n<\/pre>\n<h4><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/04\/java-bufferedreader-class.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-109024\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/04\/java-bufferedreader-class.webp\" alt=\"java bufferedreader class\" width=\"1200\" height=\"394\" \/><\/a><\/h4>\n<h4>BufferedReader class constructor in Java:<\/h4>\n<table>\n<tbody>\n<tr>\n<td><b>Constructor<\/b><\/td>\n<td><b>Description<\/b><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">BufferedReader(Reader rd)<\/span><\/td>\n<td><span style=\"font-weight: 400\">This method creates a buffered character input stream that uses the system default input buffer size.<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">BufferedReader(Reader rd, int size)<\/span><\/td>\n<td><span style=\"font-weight: 400\">This method creates a buffered character input stream of the specified size for an input buffer.<\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4>Methods in Java BufferedReader Class<\/h4>\n<table>\n<tbody>\n<tr>\n<td><b>Method<\/b><\/td>\n<td><b>Description<\/b><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">int read()<\/span><\/td>\n<td><span style=\"font-weight: 400\">This method takes a single character input.<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">int read(char[] cbuf, int off, int len)<\/span><\/td>\n<td><span style=\"font-weight: 400\">This method takes characters as input and puts them into an array.<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">boolean markSupported()<\/span><\/td>\n<td><span style=\"font-weight: 400\">This method tests the input stream support for the mark and reset method.<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">String readLine()<\/span><\/td>\n<td><span style=\"font-weight: 400\">This method takes string input.<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">boolean ready()<\/span><\/td>\n<td><span style=\"font-weight: 400\">This method tests whether the input stream is ready to be read.<\/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\">This method skips a specified length of character.<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">void reset()<\/span><\/td>\n<td><span style=\"font-weight: 400\">This method repositions the stream at a position where the mark method was last called on this input stream.<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">void mark(int readAheadLimit)<\/span><\/td>\n<td><span style=\"font-weight: 400\">This method helps in marking the present position in a stream.<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">void close()<\/span><\/td>\n<td><span style=\"font-weight: 400\">This method helps in closing the input stream and releases any of the system resources associated with the stream.<\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4>Advantages of using BufferedReaderClass<\/h4>\n<ul>\n<li>The information entered through the BufferedReader class is cradled for productive perusal.<\/li>\n<li>Methods such as readline() improve the readability of the text.<\/li>\n<li>It is ideal for faster reading as it takes the data in its original form and does not perform any partitioning of the text.<\/li>\n<\/ul>\n<h4>Disadvantages of Using BufferedReaderClass<\/h4>\n<ul>\n<li>The code that is wrapped inside the BufferedReader Class is difficult to recall.<\/li>\n<li>This class can only read the files containing plain text. It is not suitable for reading other files like binary files, files containing images, etc.<\/li>\n<\/ul>\n<p><strong>Code to understand BufferedReader Input:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">package com.DataFlair.ConsoleInput;\r\nimport java.io.BufferedReader;\r\nimport java.io.IOException;\r\nimport java.io.InputStreamReader;\r\npublic class BufferedReaderInput\r\n{\r\n    public static void main(String[] args) throws IOException \r\n    {\r\n        BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); \r\n        System.out.println(\"Enter anything: \");\r\n        String str = br.readLine();\r\n        System.out.println(\"You have Entered: \");\r\n        System.out.println(str);        \r\n    }\r\n}\r\n<\/pre>\n<p><strong>The output of the above code:<\/strong><\/p>\n<div class=\"code-output\">Enter anything:<br \/>\nDataFlair<br \/>\nYou have Entered:<br \/>\nDataFlair<\/div>\n<p><strong>Code to take Input using java BufferedReader until the User enters any specified character:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">package com.DataFlair.ConsoleInput;\r\nimport java.io.BufferedReader;\r\nimport java.io.IOException;\r\nimport java.io.InputStreamReader;\r\npublic class BufferedReaderInput2\r\n{\r\n    public static void main(String[ ] args) throws IOException \r\n    {\r\n        BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); \r\n        String str = \"\"; \r\n        System.out.println(\"Enter the Strings and when you want to stop entering the Strings, type \u2018.\u2019\");\r\n        while(!str.equals(\".\"))\r\n        { \r\n            System.out.println(\"Enter a String: \"); \r\n            str = br.readLine(); \r\n            System.out.println(\"The String input is: \"+str); \r\n            if(str.contentEquals(\".\"))\r\n                System.out.println(\"FullStop!!!\");\r\n        } \r\n        br.close(); \r\n    }  \r\n}\r\n<\/pre>\n<p><strong>The output of the above code is:<\/strong><\/p>\n<div class=\"code-output\">Enter the Strings and when you want to stop entering the Strings, type \u2018.\u2019<br \/>\nEnter a String:<br \/>\nDataFlair<br \/>\nThe String input is: DataFlair<br \/>\nEnter a String:<br \/>\nJava Tutorial<br \/>\nThe String input is: Java Tutorial<br \/>\nEnter a String:<br \/>\nConsole Input<br \/>\nThe String input is: Console Input<br \/>\nEnter a String:<br \/>\n.<br \/>\nThe String input is: .<br \/>\nFullStop!!!<\/div>\n<h4>Point to Remember:<\/h4>\n<p>The readLine() method only takes String input. To take inputs of other data types, we have to parse the Input in the following way:<\/p>\n<ul>\n<li><strong>Integer.parseInt(br.readLine()):<\/strong> To take integer value.<\/li>\n<li><strong>Double.parseDouble(br.readLine()):<\/strong> To take double value.<\/li>\n<li><strong>Float.parseFloat(br.readLine()):<\/strong> To take float value.<\/li>\n<\/ul>\n<h4>2. Java Scanner Class<\/h4>\n<p>The Scanner class also known as the utility scanner is part of java.util package. The Scanner class is simpler and better than BufferedReader. It takes input in the console or the command line.<br \/>\nThe Scanner class can also be used to parse strings and primitive types with the help of the Java regular expressions.<br \/>\nWe can create a Scanner class object using the following statement:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">Scanner sc = new Scanner(System.in);\r\n<\/pre>\n<h4>Advantages of using the Java Scanner class<\/h4>\n<ul>\n<li>It is simple to use and is very fast.<\/li>\n<li>It provides useful methods like nextInt(), nextDouble(), nextFloat(), etc, for parsing primitive data types from tokenized input.<\/li>\n<li>Also, it uses regular expressions, which we can use to find tokens.<\/li>\n<\/ul>\n<h4>Disadvantages of Using the Java Scanner Class<\/h4>\n<ul>\n<li>The methods of the scanner class are not synchronized.<\/li>\n<\/ul>\n<h4>Methods present in the Java Scanner Class:<\/h4>\n<table>\n<tbody>\n<tr>\n<td><b>Method<\/b><\/td>\n<td><b>Description<\/b><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">int nextInt()<\/span><\/td>\n<td><span style=\"font-weight: 400\">This method is used to parse the next token of the input as an integer.<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">float nextFloat()<\/span><\/td>\n<td><span style=\"font-weight: 400\">This method parses the next token of the input as a float.<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">double nextDouble()<\/span><\/td>\n<td><span style=\"font-weight: 400\">This method is used to parse the next token of the input as a double.<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">byte nextByte()<\/span><\/td>\n<td><span style=\"font-weight: 400\">This method is used to parse the next token of the input as a byte.<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">String nextLine()<\/span><\/td>\n<td><span style=\"font-weight: 400\">This method moves the scanner past the current line.<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">boolean nextBoolean()<\/span><\/td>\n<td><span style=\"font-weight: 400\">This method parses the next token of the input as a boolean value.<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">long nextLong()<\/span><\/td>\n<td><span style=\"font-weight: 400\">This method is used to parse the next token of the input as a long.<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">short nextShort()<\/span><\/td>\n<td><span style=\"font-weight: 400\">This method is used to parse the next token of the input as a Short.<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">BigInteger nextBigInteger()<\/span><\/td>\n<td><span style=\"font-weight: 400\">This method is used to parse the next token of the input as a Big Integer.<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">BigDecimal nextBigDecimal()<\/span><\/td>\n<td><span style=\"font-weight: 400\">This method is used to parse the next token of the input as a Big Decimal.<\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><strong>Code to take user input using Scanner Class:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">package com.DataFlair.ConsoleInput;\r\nimport java.util.*;\r\npublic class ScannerClassInput\r\n{\r\n    public static void main(String args[])\r\n    {\r\n        Scanner sc = new Scanner(System.in);\r\n        System.out.println(\"Enter a String\");\r\n        String str = sc.nextLine();\r\n        System.out.println(\"The String is: \" +str);\r\n        System.out.println(\"Enter an Integer\");\r\n        int i = sc.nextInt();\r\n        System.out.println(\"The Integer is: \" +i);\r\n        System.out.println(\"Enter a Float value\");\r\n        float f = sc.nextFloat();\r\n        System.out.println(\"The Float value is: \" +f);\r\n    }\r\n}\r\n<\/pre>\n<p><strong>The output of the above code is:<\/strong><\/p>\n<div class=\"code-output\">Enter a String<br \/>\nDataFlair<br \/>\nThe String is: DataFlair<br \/>\nEnter an Integer<br \/>\n21<br \/>\nThe Integer is: 21<br \/>\nEnter a Float value<br \/>\n123.456<br \/>\nThe Float value is: 123.456<\/div>\n<h4>3. Java Console Class<\/h4>\n<p>Using the console class in Java, we can get input from the console. The console class provides methods to take input as text or a password. If we want to take password input, it will not be shown on the screen. The Console class is part of the java.io package and was introduced with the Java 1.5 update.<\/p>\n<p><strong>The declaration of the console class can be given as:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">public final class Console extends Object implements Flushable  \r\n\r\n<\/pre>\n<p>To instantiate an object of the Console class, we have to write the following:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">Console c=System.console();  \r\n<\/pre>\n<h4>Advantages of Using the Java Console Class<\/h4>\n<ul>\n<li>Using the console class, we can enter passwords without displaying them on the screen.<\/li>\n<li>The Reading methods present inside the Console class are synchronized.<\/li>\n<li>The Console Class lets us use the Format String Syntax.<\/li>\n<\/ul>\n<h4>Disadvantages of using Console Class<\/h4>\n<ul>\n<li>Does not work in an IDE, only works on Command Prompt.<\/li>\n<\/ul>\n<h4>The methods present in the console class are:<\/h4>\n<table>\n<tbody>\n<tr>\n<td><b>Method<\/b><\/td>\n<td><b>Description<\/b><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">Reader reader()<\/span><\/td>\n<td><span style=\"font-weight: 400\">This method retrieves the reader object associated with the console<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">String readLine()<\/span><\/td>\n<td><span style=\"font-weight: 400\">This method helps in reading a single line of text from the console.<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">String readLine(String fmt, Object&#8230; args)<\/span><\/td>\n<td><span style=\"font-weight: 400\">This method provides a formatted prompt then reads the single line of text from the console.<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">char[] readPassword()<\/span><\/td>\n<td><span style=\"font-weight: 400\">This method reads a password that is not being displayed on the console.<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">char[] readPassword(String fmt, Object&#8230; args)<\/span><\/td>\n<td><span style=\"font-weight: 400\">This method provides a formatted prompt then reads the password that is not being displayed on the console.<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">Console format(String fmt, Object&#8230; args)<\/span><\/td>\n<td><span style=\"font-weight: 400\">This method helps in writing a formatted string to the console output stream.<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">Console printf(String format, Object&#8230; args)<\/span><\/td>\n<td><span style=\"font-weight: 400\">This method writes a string to the console output stream.<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">PrintWriter writer()<\/span><\/td>\n<td><span style=\"font-weight: 400\">This method helps to retrieve the PrintWriter object associated with the console.<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">void flush()<\/span><\/td>\n<td><span style=\"font-weight: 400\">This method flushes the console.<\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><strong>Code to take input using the Console class:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">package com.DataFlair.ConsoleInput;\r\nimport java.io.Console; \r\npublic class ConsoleClassInput\r\n{ \r\n    public static void main(String args[])\r\n    {    \r\n        Console c=System.console();    \r\n        System.out.println(\"Enter a String: \");    \r\n        String Str=c.readLine();    \r\n        System.out.println(\"The String is: \"+Str);    \r\n    }    \r\n} \r\n<\/pre>\n<p><strong>The output of the above code is:<\/strong><\/p>\n<div class=\"code-output\">Enter a String:<br \/>\nDataFlair<br \/>\nThe String is: DataFlair<\/div>\n<p><strong>Code to take password as input:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">package com.DataFlair.ConsoleInput;\r\nimport java.io.*;\r\npublic class ConsolePasswordInput\r\n{\r\n    public static void main(String args[])\r\n    {    \r\n        Console c=System.console();    \r\n        System.out.println(\"Enter password: \");    \r\n        char[] passcode=c.readPassword();    \r\n        String pass=String.valueOf(passcode);  \r\n        System.out.println(\"The Password is: \"+pass);    \r\n    }    \r\n}\r\n<\/pre>\n<p><strong>The output of the above code is:<\/strong><\/p>\n<div class=\"code-output\">Enter password:<br \/>\nThe Password is: DataFlair<\/div>\n<h4>4. Using Java Command Line Argument<\/h4>\n<p>In java, we can also use the Command Line Argument to take inputs directly. If we recall the syntax of the main method, it is written as:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">public static void main(String args[])<\/pre>\n<p>The String args lets us take input through the command line, it stores the input in the args[] array, which can be accessed inside the code.<\/p>\n<h4>Advantages of Using Command Line Arguments in Java<\/h4>\n<ul>\n<li>Using Command Line Arguments, we can pass any number of arguments.<\/li>\n<li>The input in the Command Line Arguments is in String form, thus they can be converted to any data type easily.<\/li>\n<\/ul>\n<p><strong>Code to understand Command-Line Argument:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">package com.DataFlair.ConsoleInput;\r\npublic class CLA\r\n{\r\n    public static void main(String args[])\r\n    {\r\n        System.out.println(\"The input through Command Line Argument is: \");\r\n        for(int i=0;i&lt;args.length;i++)\r\n        {\r\n            System.out.println(args[i]);\r\n        }\r\n    }\r\n}\r\n<\/pre>\n<p><strong>The output of the above code is:<\/strong><\/p>\n<div class=\"code-output\">The input through Command Line Argument is:<br \/>\nDataFlair<\/div>\n<h3>Conclusion<\/h3>\n<p>In this article, we saw how to use all three ways in which we can take console input in Java. Each of these classes has its own advantages and disadvantages. It is the duty of the programmer to decide which class they want to use in their program. Knowing how to take user input is very important, as this will help in creating an interactive program and add a better user experience.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>A programmer cannot always assume what the user wants to input into the program. Most of the time, it is a necessity to make the program interactive. To make the program interactive, the programmer&#46;&#46;&#46;<\/p>\n","protected":false},"author":5,"featured_media":108856,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[32],"tags":[2916,4348,7409,7440,7546,11359,12612],"class_list":["post-13717","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-java","tag-console-class-in-java","tag-example-of-scanner-class-in-java","tag-java-bufferedreader-class","tag-java-console","tag-java-input","tag-read-java-input","tag-scanner-class-in-java"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.8 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>How to Read Java Console Input | 3 Ways To Read Java Input - DataFlair<\/title>\n<meta name=\"description\" content=\"Java Console Tutorial-how to read input from console in Java: Java Bufferedreader Class, Scanner Class in Java, Console Class in Java.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/data-flair.training\/blogs\/read-java-console-input\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Read Java Console Input | 3 Ways To Read Java Input - DataFlair\" \/>\n<meta property=\"og:description\" content=\"Java Console Tutorial-how to read input from console in Java: Java Bufferedreader Class, Scanner Class in Java, Console Class in Java.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/data-flair.training\/blogs\/read-java-console-input\/\" \/>\n<meta property=\"og:site_name\" content=\"DataFlair\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/DataFlairWS\/\" \/>\n<meta property=\"article:published_time\" content=\"2018-04-27T09:12:46+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-05-30T11:16:55+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/04\/java-console-input.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=\"DataFlair Team\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@DataFlairWS\" \/>\n<meta name=\"twitter:site\" content=\"@DataFlairWS\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"DataFlair Team\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"7 minutes\" \/>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to Read Java Console Input | 3 Ways To Read Java Input - DataFlair","description":"Java Console Tutorial-how to read input from console in Java: Java Bufferedreader Class, Scanner Class in Java, Console Class in Java.","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:\/\/data-flair.training\/blogs\/read-java-console-input\/","og_locale":"en_US","og_type":"article","og_title":"How to Read Java Console Input | 3 Ways To Read Java Input - DataFlair","og_description":"Java Console Tutorial-how to read input from console in Java: Java Bufferedreader Class, Scanner Class in Java, Console Class in Java.","og_url":"https:\/\/data-flair.training\/blogs\/read-java-console-input\/","og_site_name":"DataFlair","article_publisher":"https:\/\/www.facebook.com\/DataFlairWS\/","article_published_time":"2018-04-27T09:12:46+00:00","article_modified_time":"2026-05-30T11:16:55+00:00","og_image":[{"width":1200,"height":628,"url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/04\/java-console-input.webp","type":"image\/webp"}],"author":"DataFlair Team","twitter_card":"summary_large_image","twitter_creator":"@DataFlairWS","twitter_site":"@DataFlairWS","twitter_misc":{"Written by":"DataFlair Team","Est. reading time":"7 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/data-flair.training\/blogs\/read-java-console-input\/#article","isPartOf":{"@id":"https:\/\/data-flair.training\/blogs\/read-java-console-input\/"},"author":{"name":"DataFlair Team","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/person\/7f83c342f5d1632d6f7b4b0b0f447823"},"headline":"How to Read Java Console Input | 3 Ways To Read Java Input","datePublished":"2018-04-27T09:12:46+00:00","dateModified":"2026-05-30T11:16:55+00:00","mainEntityOfPage":{"@id":"https:\/\/data-flair.training\/blogs\/read-java-console-input\/"},"wordCount":1471,"commentCount":1,"publisher":{"@id":"https:\/\/data-flair.training\/blogs\/#organization"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/read-java-console-input\/#primaryimage"},"thumbnailUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/04\/java-console-input.webp","keywords":["Console class in Java","Example of Scanner Class in Java","java bufferedreader class","Java Console","Java Input","Read Java input","scanner class in java"],"articleSection":["Java Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/data-flair.training\/blogs\/read-java-console-input\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/data-flair.training\/blogs\/read-java-console-input\/","url":"https:\/\/data-flair.training\/blogs\/read-java-console-input\/","name":"How to Read Java Console Input | 3 Ways To Read Java Input - DataFlair","isPartOf":{"@id":"https:\/\/data-flair.training\/blogs\/#website"},"primaryImageOfPage":{"@id":"https:\/\/data-flair.training\/blogs\/read-java-console-input\/#primaryimage"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/read-java-console-input\/#primaryimage"},"thumbnailUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/04\/java-console-input.webp","datePublished":"2018-04-27T09:12:46+00:00","dateModified":"2026-05-30T11:16:55+00:00","description":"Java Console Tutorial-how to read input from console in Java: Java Bufferedreader Class, Scanner Class in Java, Console Class in Java.","breadcrumb":{"@id":"https:\/\/data-flair.training\/blogs\/read-java-console-input\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/data-flair.training\/blogs\/read-java-console-input\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/data-flair.training\/blogs\/read-java-console-input\/#primaryimage","url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/04\/java-console-input.webp","contentUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/04\/java-console-input.webp","width":1200,"height":628,"caption":"java console input"},{"@type":"BreadcrumbList","@id":"https:\/\/data-flair.training\/blogs\/read-java-console-input\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Blog Home","item":"https:\/\/data-flair.training\/blogs\/"},{"@type":"ListItem","position":2,"name":"Java Tutorials","item":"https:\/\/data-flair.training\/blogs\/category\/java\/"},{"@type":"ListItem","position":3,"name":"How to Read Java Console Input | 3 Ways To Read Java Input"}]},{"@type":"WebSite","@id":"https:\/\/data-flair.training\/blogs\/#website","url":"https:\/\/data-flair.training\/blogs\/","name":"DataFlair","description":"Learn Today. Lead Tomorrow.","publisher":{"@id":"https:\/\/data-flair.training\/blogs\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/data-flair.training\/blogs\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/data-flair.training\/blogs\/#organization","name":"DataFlair","url":"https:\/\/data-flair.training\/blogs\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/logo\/image\/","url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2016\/07\/Data-Flair.png","contentUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2016\/07\/Data-Flair.png","width":106,"height":48,"caption":"DataFlair"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/DataFlairWS\/","https:\/\/x.com\/DataFlairWS","https:\/\/www.linkedin.com\/company\/dataflair-web-services-pvt-ltd\/","https:\/\/www.youtube.com\/user\/DataFlairWS"]},{"@type":"Person","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/person\/7f83c342f5d1632d6f7b4b0b0f447823","name":"DataFlair Team","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/4cf3a74600d131330b8c481d519afd1574093ed89f6d3396a95393ad223eb7cd?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/4cf3a74600d131330b8c481d519afd1574093ed89f6d3396a95393ad223eb7cd?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/4cf3a74600d131330b8c481d519afd1574093ed89f6d3396a95393ad223eb7cd?s=96&d=mm&r=g","caption":"DataFlair Team"},"description":"DataFlair Team creates expert-level guides on programming, Java, Python, C++, DSA, AI, ML, data Science, Android, Flutter, MERN, Web Development, and technology. Our goal is to empower learners with easy-to-understand content. Explore our resources for career growth and practical learning.","url":"https:\/\/data-flair.training\/blogs\/author\/dfteam1\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/13717","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/comments?post=13717"}],"version-history":[{"count":12,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/13717\/revisions"}],"predecessor-version":[{"id":148548,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/13717\/revisions\/148548"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/media\/108856"}],"wp:attachment":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/media?parent=13717"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/categories?post=13717"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/tags?post=13717"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}