Java Programming - Getting the input from the keyboard

Java Programming - Getting the input from the keyboard

I need a Java program to take a input from the keyword.

View Answers

February 27, 2008 at 4:32 PM

For getting the input from the keyboard you used this line of code it will not create the error because

BufferedReader object = new BufferedReader(new InputStreamReader(System.in));

System.in is a byte stream that has no character stream features. To use Standard Input as a character stream, wrap System.in within the InputStreamReader as an argument.

InputStreamReader inp = new InputStreamReader(system.in);



In your program you used this line of code DataInputStream object =new DataInputStream (new InputStream(System.in));.....

it will create the errors like this

Factorial.java:24: java.io.InputStream is abstract; cannot be instantiated
DataInputStream object =new DataInputStream (new InputStream(System.in));
^
Note: Factorial.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
1 error

Because InputStream class is the abstract class we can't create an instance of this class and DataInputStream is used for the following purpose .

DataInputStream:

This class is a type of FilterInputStream that allows you to read binary data of Java primitive data types in a portable way. In other words, the DataInputStream class is used to read binary Java primitive data types in a machine-independent way. An application uses a DataOutputStream to write data that can later be read by a DataInputStream.

Java Input Output Examples
Resources - http://www.roseindia.net/java/example/java/io/









Related Tutorials/Questions & Answers:
keyboard input
keyboard input  how do I use JOptionPane to accept keyboard input? I know how to import but not specific command on input line   import javax.swing.*; class JOPtionPaneExample { public static void main(String
how to use marathi keyboard in java programming?
how to use marathi keyboard in java programming?  how to use Marathi keyboard in java programming
Advertisements
How to Create Keyboard in JAVA
How to Create Keyboard in JAVA  please help me to create On-Screen Keyboard with java and please give me an another idia to make it ..............iam waiting for your help ,think u so much
disable keyboard in java applet
disable keyboard in java applet  How to disable key board of my client in an java applet embedded in a website while the applet is running.? Plz help
java keyboard shortcuts - Struts
java keyboard shortcuts  hi, i hav an application already developed using struts framework.now i would like to add some keboard shortcuts to my application, so that the user need not to go for the usage of the mouse every time
How to read data dynamically from keyboard to array in flex
How to read data dynamically from keyboard to array in flex  How to read data dynamically from keyboard to array in flex
write a program to remove the element from hashset using keyboard.
write a program to remove the element from hashset using keyboard.  write a program to remove the element from hashset using keyboard
How do I learn Java programming in one day from zero?
How do I learn Java programming in one day from zero?  Hi, I am total beginner in Java programming checking if anyone can learn Java quickly... programming language in one day from zero? Thanks   Hi, Java is so
How do I learn Java programming in one day from zero?
How do I learn Java programming in one day from zero?  Hi, I am total beginner in Java programming checking if anyone can learn Java quickly... programming language in one day from zero? Thanks   Hi, Java is so
programming language definition you can learn apart from java
programming language definition you can learn apart from java  Hi, I am learning Java to make an entry into the programming field. I just wanted... to learn and use the Java programming language. So, these websites are best place
error in taking input from user.
error in taking input from user.  //i m having problem inputting the array from user.my program is import java.io.*; class bubble { public static void main(String args[]) { int a[]=new int[20]; int i=0; BufferedReader br=new
Input From Console
Input From Console     ... and implements flushable interface. The Input from Console is used to access the character... in understanding a code Input from Console. For this we have a class 'Input From Console
how java programming differ from pascal and C - Java Beginners
how java programming differ from pascal and C  how Does the Java programming language differs from Procedural languages such as Pascal and C.when ýt... and Pascal are both arguably descendants of the ALGOL programming language series. ALGOL
how to transliterate the input from english to japanese
how to transliterate the input from english to japanese  Hi everyone , I am trying to make an application in java in which i want to get input from... possible in java :) please help me please :) Thanks In Advance
Input / Output in Easiest Method in Java
Input / Output in Easiest Method in Java  How to input from keyboard... with the easiest method in Java?   Hi Friend, Try the following code: import...)throws Exception{ Scanner input=new Scanner(System.in
Ask make graph from i report and view to java Language Programming
Ask make graph from i report and view to java Language Programming  Dear sir, Please help me, i want to make a graph from mysql to i report and view to java. Please help me, give me example source code please. thank you
java user input - Java Beginners
java user input  how to input from keyboard? please give a example.  Hi Friend, There are lot of ways to input data from keyboard.You...:****** try{ System.out.print("Enter String:"); BufferedReader input = new
Count repetitions of every word from an input file
Count repetitions of every word from an input file  Hello..i got to know how can i count the repetitions of every word present in a specific input file?For suppose if i have a url log file which have time,url's,ip address etc
How to create file from input values in Jframe ?
How to create file from input values in Jframe ?  hi i m doing my project using java desktop application in netbeans.i designed a form to get... the inputs given by the user.i had a java program for it and accessed it by creating
JavaScript Array from Input
JavaScript Array from Input   ... you easy to understand an example of  Array from Input. The example create a HTML Page JavaScript array from input include a text name 'name', a text field
Java programming - Java Beginners
Java programming  hi sir, my question are as follows... hope u can solve my java programming problem.. Write a program to develop a class to hold... keyboard input.   Hi friend, For solving the problem visit
java programming - Java Beginners
java programming  write and run a programme that accept a string from keyboard and convert it into a number.  Hi Friend, Please visit.../StringToInt.shtml IF you want to generate hashcode from input string then try
Java Command Line Input
Java Command Line Input  How to get input from command line in java ?   Hi please Find the code for inputting data from the command line System.out.println("Please Input A Number"); BufferedReader br
Java get User Input
Java get User Input       In this section, you will learn how to get the user input from... input. The br.readline() method reads the name from the command line. After
Java Programming
Java Programming  Hi, What is Java Programming? How I can learn Java Programming in one month? Thanks
Swap two any numbers (from Keyboard)
Swap two any numbers (from Keyboard)   .... If  you are newbie in Java programming then our tutorial and example are helpful for understanding Java programming in the simplest way.  Here we
input - Java Beginners
to input the data from the command prompt. Try the following code to input name...input  i want to know how to take value from user in core java.help me soon.  Hi Friend, There are lot of ways to input data.You can use
Read user input in Java using Scanner
Example of of reading user input in Java using Scanner In this section we... input from console. Our sample program asks user to enter name and then age, user... back on the console. There are various ways to read user input in Java
different type input in java
type of input method. thank   Java Read through DataInputStream: import...); } }   Java read input through Scanner: import java.util.*; class...); } }   Java read input through BufferedReader import java.io.*; public class
java input problem - Java Beginners
java input problem  I am facing a Java input problem
input
input  a java program that will exchange the last names of two students that were input by a user
how to read 100 text files from a folder or directory and write the data into a single file.using java programming?
how to read 100 text files from a folder or directory and write the data into a single file.using java programming?  i have multiple(app..100) text... column value that keeps on changing for every file.i have read the data from all
write a java pogram to add elements to linked list using keyboard and display it
write a java pogram to add elements to linked list using keyboard and display it  write a java pogram to add elements to linked list using keyboard and display
Java User Input
Java User Input  I am using Scanner class for user Input. Scanner s = new Scanner(System.in); String name = s.next(); but i am unable to store full name in name variable...how i can store full name plsss reply   use
input output in java
input output in java  java program using filereader and filewriter   Hi Friend, Try the following code: import java.io.*; class FileInputStreamAndFileOutputStream { public static void main(String[] args) throws
java programming
java programming  WAP to find the longest word from a user given string.   The given code finds the longest word from the string. import java.util.*; class LongestWord { Scanner input=new Scanner(System.in
java programming
java programming  WAP to accept 10 strings from the user and find out... that accepts 10 strings from the string and stored into array and then find...){ String word = ""; Scanner input=new Scanner(System.in); String stringArray[] = new
Java programming
Java programming  To make a fraction to a representation base 16... but now base 16. Your code should work for any length input array, not just one... input array
how to pass input from radio button to jsp page
how to pass input from radio button to jsp page  hi.. the code below... are matched from database. I want to pass the selected value in Struts Action FormBean..."><label> <input name="radiobutton" type="radio" value
how to pass input from radio button to jsp page
how to pass input from radio button to jsp page  hi.. the code below... are matched from database. I want to pass the selected value in Struts Action FormBean..."><label> <input name="radiobutton" type="radio" value
how to pass input from radio button to jsp page
how to pass input from radio button to jsp page  hi.. the code below... are matched from database. I want to pass the selected value in Struts Action FormBean..."><label> <input name="radiobutton" type="radio" value
Command Line Standard Input In Java
. These input data can be read from the keyboard input, file input or any other input...Command Line Standard Input In Java In this section we will discuss about the Java IO Standard Input through Command Line. Standard streams, feature
java programming
java programming   Companies and people often buy and sell stocks... in question Implement the program described above using the Java programming language... programming method you want to accomplish this task. Both your stack and queue
java programming
java programming   Companies and people often buy and sell stocks... in question Implement the program described above using the Java programming language... programming method you want to accomplish this task. Both your stack and queue
programming - Java Beginners
programming for java beginners  How to start programming for java beginners
programming - Java Beginners
Start programming in Java  Programming in Java - Can any one please suggest how to start programming in Java
Java programming - Java Beginners
Java programming  Write a java program Grep for searching the input... number and the text for every line in which word appears. The input comes from standard input unless filename is present, in which case it is read from filename
virtual onscreen keyboard project using java and swings - Swing AWT
virtual onscreen keyboard project using java and swings  sir thanks a lot for ur reply for my last question, can u please send me the entire project code of virtual on screen keyboard.i did but im not sure as it was right
java programming
java programming  Hi friend if you have any idea about this statement please tel me... String qry1="select * from custentry1 where custid='"+custno
java programming
java programming  supose i have a text field in java (like in gmail home page u have username field ) so i want to fill that field automatically by taking record from the database so is there any mechanism in java to handle

Ads