java user input

java user input

View Answers

June 12, 2009 at 12:57 PM

Hi Friend,

There are lot of ways to input data from keyboard.You can use BufferedReader class, Scanner class, StreamTokenizer class and their methods.

*******Use BufferedReader class in main method in following way:******

try{
System.out.print("Enter String:");
BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
String data= input.readLine();
System.out.print("You have entered: "+data);
}
catch(Exception e) {
e.printStackTrace();
}

*******Use Scanner class in main method in following way:*******
String name;
Scanner in = new Scanner(System.in);
System.out.println("Enter String:");
name = in.nextLine();
in.close();
System.out.println("You have entered: " + name);
}
********Use StreamTokenizer class in main method in following way:*******
StreamTokenizer Input=new StreamTokenizer(System.in);
try {
System.out.print(" Enter String: ");
Input.nextToken();
System.out.println("You have entered:"+Input.sval);
}
catch (Exception e) {
e.printStackTrace();
}









Related Tutorials/Questions & Answers:
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
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
Advertisements
user input in java - Java Beginners
user input in java   i am trying to write a code to compute the average of 5 numbers but i dont know what to do for the program to accept user input  Hi import java.util.*; public class AverageExample { public
Java get User Input
Java get User Input       In this section, you will learn how to get the user input from... that will communicate with the user at the command line and returns the user input. We have
escaping user input in php
escaping user input in php  Is it possible to escape the user input while submitting data into database in PHP
Read user input in Java using Scanner
Example of of reading user input in Java using Scanner In this section we are explaining the use of Scanner class in Java which can be used to read user... back on the console. There are various ways to read user input in Java
button to accept user input
the radiobutton and spinner.The user input does not show on my Studentinfo.mdb database it just gives me an error.please help   Here is java swing example...button to accept user input  private void jButton1ActionPerformed
user input to database
user input to database  /* * Studentinfo2App.java */ package studentinfo2; import java.sql.Connection; import java.sql.DriverManager; import... in my database user input from my applet does not show
user input to database
user input to database  /* * Studentinfo2App.java */ package studentinfo2; import java.sql.Connection; import java.sql.DriverManager; import... in my database user input from my applet does not show
user input to database
user input to database  /* * Studentinfo2App.java */ package studentinfo2; import java.sql.Connection; import java.sql.DriverManager; import... in my database user input from my applet does not show
calculation after if. user input
user input????   My apologies good evening peoples Once again I am...calculation after if. user input  System.out.print ("please select...[]args){ Scanner input=new Scanner(System.in); System.out.print
How to read user input in C++
How to read user input in C++  How can i get an input from the users in C++?   You can use the standard input "cin" to get the input from user.. For example: int age; cin >> age
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
XP Bowling Game User input help
XP Bowling Game User input help  I was asked to do the XP Bowling... to make the code accept input from a user and display the scores/frames in a command window. Being new to Java....I have no clue how to out put it to the console
How to take input by user using jDialogue and use that input
How to take input by user using jDialogue and use that input  I am using NetBeans i have a 'Search by employee id' button . I want when user click this button a dialogue box appear which take employee_id as input from user
Design a registration.jsp page with input for user registration details
Design a registration.jsp page with input for user registration details  Design a registration.jsp page with input for user registration details like firstname, lastname, choose username, choose password, confirm password. After
Save the input data until user get changed
Save the input data until user get changed  I would like to know how to store the give input data and perform the calculations even after re-opening the program. I am developing a college library management system, i would like
Save the input data until user get changed
Save the input data until user get changed  I would like to know how to store the give input data and perform the calculations even after re-opening the program. I am developing a college library management system, i would like
Save the input data until user get changed
Save the input data until user get changed  I would like to know how to store the give input data and perform the calculations even after re-opening the program. I am developing a college library management system, i would like
Write a program that takes the marks of user as input
Write a program that takes the marks of user as input  Write a program that takes the marks of user as input. If marks are greater then 60 the program should display "Great, you have passed the course", else the program should
Managing Multiple User Input Data in an Array (or ArrayList)
Managing Multiple User Input Data in an Array (or ArrayList)  Hey... record alphabetically (2) If user chooses choice1, the input data is stored in an ARRAY (or ARRAYLIST) until the user chooses to stop inputting data. Kindly
Display PHP clock with user input date and time
Display PHP clock with user input date and time  The following PHP code displays a clock with current date and time. I want the clock to receive user input date and time. How can this be done? <?php date<em>
input
input  a java program that will exchange the last names of two students that were input by a user
Getting ISD code when user input country name
Getting ISD code when user input country name  I want to create program which user needs by typing Country name he will get ISD code of that country... code, from that list i have to read the file and when user input any country name
input - Java Beginners
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... to input the data from the command prompt. Try the following code to input name
Java Command Line Input
Java Command Line Input  How to get input from command line in java... System.out.println("Please Input A Number"); BufferedReader br... this code you will find the output as Please Input A Number 2 data is- 2
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 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
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
How to get the unicode of japanese character input in java
How to get the unicode of japanese character input in java  Good Evening sir/madam; I am trying to create an application in java which needs to show... the user to check their vocabulary.But I stuck in the middle coz if user enters
Servlet Error Message based on user input
Servlet Error Message based on user input   ... to check the user input against database and display the message to the user. This example illustrate how to ensure that user input is correct by validating
Input and Output problems - Java Beginners
Input and Output problems  1) what is Difference between... to a particular platform. Thus, this class reads characters from a byte input stream.... This link will help you. http://www.roseindia.net/java/beginners
need help with two dimensional array that takes input from user and bubble sorts and selections sorts
need help with two dimensional array that takes input from user and bubble sorts and selections sorts  I can get both of the sorts figured out but i... how many elements are going to be input by the user?   Here is a code
Command Line Standard Input In Java
Command Line Standard Input In Java In this section we will discuss about the Java IO Standard Input through Command Line. Standard streams, feature of various O/S, are read through standard input in Java. Standard streams are read
Validation on input xml in java program - XML
Validation on input xml in java program  Hi.. i am accepting xml data as input which I have to use in my program. i have to validate this input xml against some schema using xml beans and NOT by using sax or dom parser. I am
Java User Validation
Java User Validation  Dear Deepak thanks for your help with my previous problem. I am looking to write a program that allows a user of a web... user in the database and add encrypted password(Please provide a java program
Java Graphical user interface
Java Graphical user interface  Hi, guys. I'm christina, need help with my home work Task 1: GUI Design and Implementation The user requirements of your Java quiz GUI application are specified by the following program flow
Array and input
[ ]={1,2,3,4,5,6,7,8,9,10,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26}; i want to ask user to input one of the above numbers then i want to print the array without the number user input. how will i do tht
input box
input box  give me the code of input box in core java
input box
input box  give me the code of input box in core java
Java Input/Output Examples
Java Input/Output Examples In this tutorial you will learn about how the Inputs and outputs are managed in java. To understand the Java Input & Output there is a package in java named java.io which provides the classes
input ang message box - Java Beginners
input ang message box  can you help me to calculates for the sum, difference, product and quotient of the two inputted values using Input Dialog...("Input First Number"); int num1=Integer.parseInt(input1); String input2
blank space in input field - Java Beginners
blank space in input field  I retrieved the fields from my mysql table...If the field contains null value i want to display a blank space in input field(text box)..but i am displaying null how to overcome this.. u r help
Java User Transaction. - Java Beginners
Java User Transaction.  Hi Experts, Could you please guide me for writing a java program of File Handling using user transaction, also please tell me which jars do I need. Please give me a program for above mentioned
Java User Transaction - Java Beginners
Java User Transaction  Hi, I am trying to do file handling through User Transaction, I would like to know that if server crashes while writing file... Operation and file handling both in one User Transaction with atomicity
input output
; Introduction The Java I/O means Java Input/Output and is a part... input to read the user input..ADS_TO_REPLACE_1 In this section, you will see how... DataInputStream A data input stream is use to read primitive Java data types from
Simple input application in Echo3
an application which contains the window from where the user can  input a text and this value would be shown into the content pane when user will click... Simple input application in Echo3   
graphical user interface - Java Beginners
graphical user interface  how do i write a code for a jmenu bar, File with items like open, save , save as. that lead to another interface? .../java/example/java/swing/SwingMenu.shtml Thanks
Maven dependency for com.bytebreakstudios - input version 1.6.0 is released. Learn to use input version 1.6.0 in Maven based Java projects
this version ( com.bytebreakstudios - input version 1.6.0 ) in their Java...Maven dependency for  com.bytebreakstudios  - Version 1.6.0 of input released The developers of   com.bytebreakstudios - input project

Ads