Home Answers Viewqa Java-Beginners Java Programming - Getting the input from the keyboard

 
 


Doshyo
Java Programming - Getting the input from the keyboard
1 Answer(s)      5 years and 3 months ago
Posted in : Java Beginners

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 Pages:
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
input output
DataInputStream A data input stream is use to read primitive Java data types from...; Introduction The Java I/O means Java Input/Output and is a part... and converting data from the java primitive data types
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
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
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
Java Programming: Solution to Programming Exercise
POSSIBLE SOLUTION to the following exercise from this on-line Java textbook... that it also responds to keyboard input. When the applet has the input focus, it should... changes from blue to red when the applet has the input focus. In order
Input And Output
DataInputStream A data input stream is use to read primitive Java data types from...; Introduction The Java I/O means Java Input/Output and is a part of java.io... This class reads the primitive data types from the input stream
input
input  a java program that will exchange the last names of two students that were input by a user
Java Programming: Solution to Programming Exercise
action while allowing keyboard input from the user to affect the action... Solution for Programming Exercise 6.6 THIS PAGE DISCUSSES ONE POSSIBLE SOLUTION to the following exercise from this on-line Java textbook
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
Dialog and Console Input-Output
Prev: Dialog Box Output | Next: Example: Captitalize Java NotesDialog and Console Input-Output  This is similar to the previous program, but it also gets input from the user. 1 2 3 4 5 6 7 8
Console Input: Scanner
Java NotesConsole Input: Scanner The java.util.Scanner class (added in Java 5) allows simple console and file input. Of course, your program should... the Scanner class from the java.util package, the most common programming style
Command Line Standard Input In Java
be read from the keyboard input, file input or any other input source depends...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  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 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
Programming Assignment
Programming Assignment  Hey there, We were given an assignment to write a program to read 10 student marks from the keyboard without using an Array (only using switch statements, if statements or loops). As each mark is input
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 Programming: Section 6.5
different key codes, but Java translates the actual codes from the keyboard... Section 6.5 Keyboard Events IN JAVA, EVENTS are associated... to be a Java component, then the information about the keyboard event becomes
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
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
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 Programming: Section 1.2
from The Most Complex Machine.) Now, devices such as keyboard, mouse... in Java and in modern programming in general is the basic concept of asynchronous... THE CPU SPENDS ALMOST ALL ITS TIME fetching instructions from memory
Read Text from Standard IO
through System.in which is used to read input from the keyboard... Reading Text from the Standard Input   ... from the keyboard and write output to the display. They also support I/O
Programming
Programming  how to save output of java file in .txt format?   Hi, If you are running the example from dos prompt you can use the > bracket to direct the output to a text file. Here is the example: C:>java
Java Programming: Solution to Programming Exercise
POSSIBLE SOLUTION to the following exercise from this on-line Java textbook... by: while (true): Get a line of input from the user...): Get a line of input from the user if the line is empty
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
Java Programming: Solution to Programming Exercise
Solution for Programming Exercise 9.3 THIS PAGE DISCUSSES ONE POSSIBLE SOLUTION to the following exercise from this on-line Java textbook... value is subtracted from the larger value. For example, IV represents 5 - 1
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
Java Programming: Section 6.6
and processes mouse, keyboard, and focus events on its own. You only hear from... and how to handle mouse events and keyboard events. In one sense, that's all there is to GUI programming. If you're willing to program all the drawing and handle
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
Java Programming, Solution to Programming Exercise
POSSIBLE SOLUTION to the following exercise from this on-line Java textbook... of the two sets of integers from the input line. Without error handling, an algorithm...() { // Reads a set of non-negative integers from standard input
iPhone Input Field, iPhone Input Field Tutorial
iPhone Input Field Generally, input fields are used to take input from the users.  In iPhone application we can use Text Field to take the input. ... "inspector" from tool bar. Select the text field and change the keyboard
Java Programming: Solution to Programming Exercise
Solution for Programming Exercise 4.2 THIS PAGE DISCUSSES ONE POSSIBLE SOLUTION to the following exercise from this on-line Java textbook...) { String hex; // Input from user, containing a hexadecimal number
Java Programming: Solution to Programming Exercise
Solution for Programming Exercise 2.3 THIS PAGE DISCUSSES ONE POSSIBLE SOLUTION to the following exercise from this on-line Java textbook... matter when it came time to read a second value from input
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
Java Programming: Solution to Programming Exercise
Solution for Programming Exercise 8.2 THIS PAGE DISCUSSES ONE POSSIBLE SOLUTION to the following exercise from this on-line Java textbook... is called just after all the numbers have been input from the user. The second
Data input & output Stream
Data input & output Stream  Explain Data Input Stream and Data Output Stream Class.   DataInputStream and DataOutputStream A data input stream lets an application read primitive Java data types from an underlying input
Java Programming, Solution to Programming Exercise
POSSIBLE SOLUTION to the following exercise from this on-line Java textbook... be read from an input file, and the concordance data should be written.... Get the next word from the input file. if the word
Java Programming, Solution to Programming Exercise
POSSIBLE SOLUTION to the following exercise from this on-line Java textbook... the words are read from the input file. Words are converted to lower... in; // A stream for reading from the input file. PrintWriter out; // A stream
Java Programming: Solution to Programming Exercise
POSSIBLE SOLUTION to the following exercise from this on-line Java textbook... must be greater than zero. The program continues to read input from...) { String line; // A line of input from the user
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
Java Programming: Solution to Programming Exercise
Solution for Programming Exercise 2.4 THIS PAGE DISCUSSES ONE POSSIBLE SOLUTION to the following exercise from this on-line Java textbook...;. After TextIO.getlnInt() reads the number 7, it will discard the extra input
Java Programming: Solution to Programming Exercise
POSSIBLE SOLUTION to the following exercise from this on-line Java textbook... subroutine with a main() routine that gets a line of input from the user and applies... will get a line of input from the user and will print a copy of the line
Java Programming: Solution to Programming Exercise
Solution for Programming Exercise 2.5 THIS PAGE DISCUSSES ONE POSSIBLE SOLUTION to the following exercise from this on-line Java textbook..., and extras to represent these quantities. The number of eggs can be read from
Java Programming: Solution to Programming Exercise
Solution for Programming Exercise 3.4 THIS PAGE DISCUSSES ONE POSSIBLE SOLUTION to the following exercise from this on-line Java textbook... line of input typed by the user. It will print the words from
Java Programming: Solution to Programming Exercise
POSSIBLE SOLUTION to the following exercise from this on-line Java textbook.... All the words are read from the input file. Words are converted... in; // A stream for reading from the input file. PrintWriter out
Java Programming, Solution to Programming Exercise
POSSIBLE SOLUTION to the following exercise from this on-line Java textbook... { // Read a term from the current line of input and // return its... { // Read a primary from the current line of input and // return
Java Programming: Solution to Programming Exercise
POSSIBLE SOLUTION to the following exercise from this on-line Java textbook... increases from ymin to ymax. You could improve the applet by adding text input boxes... the user's input string from the JTextField. It tries to use this string

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.