different type input in java

different type input in java

hiiiii... get input different different type like as DataInputStream,Scanner i want to get source code of these all type of input method. thank

View Answers

February 25, 2011 at 1:46 PM

Java Read through DataInputStream:

import java.io.*;
class  ReadFromDataInputStream{
    public static void main(String[] args) throws Exception{
            DataInputStream in = new DataInputStream(System.in);
            System.out.println("Enter Name: ");
            String name=in.readLine();
            System.out.println("Name is: "+name);
            }   
}

February 25, 2011 at 1:47 PM

Java read input through Scanner:

import java.util.*;
class  ScannerExample
{
    public static void main(String[] args) 
    {
        Scanner input=new Scanner(System.in);
        System.out.print("Enter integer: ");
        int i=input.nextInt();
        System.out.print("Enter double: ");
        double d=input.nextDouble();
        System.out.print("Enter float: ");
        float f=input.nextFloat();
        System.out.print("Enter string: ");
        String s=input.next();
        System.out.println(i);
        System.out.println(d);
        System.out.println(f);
        System.out.println(s);

    }
}

February 25, 2011 at 1:48 PM

Java read input through BufferedReader

import java.io.*;
public class ReadFromBufferedReader {
    public static void main(String[] args)throws Exception {
            BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
            System.out.println("Enter Name: ");
            String input = reader.readLine();
            System.out.println("Name is: "+name);
            }
}









Related Tutorials/Questions & Answers:
different type input in java
different type input in java  hiiiii... get input different different... type of input method. thank   Java Read through DataInputStream: import...); } }   Java read input through Scanner: import java.util.*; class
Input type select
Input type select  This block of code shows 4 countries even when the size of the SELECT element specified is 2. Why is it so? Select a Country: <select name="country" size="2"> <option name="Australia" value
Advertisements
HTML5 input attribute, Define the type, alt and image  of input tag.
HTML5 input attribute, Define the type, alt and image  of input tag. Introduction:Here we will introduce you to about the type attribute of input tag... only given type of data. It is most important for input tag. The alt 
how to enable and disable a input type in jsp - JSP-Servlet
how to enable and disable a input type in jsp  how to disable the input type and enable based on some input in the input type   Hi Friend, Try the following code: function function1(){ var n
How to get the full path location using <input type=file>
How to get the full path location using input type=file  Hi. I have used input type=file> in HTML to select an image. But it selects only the image but not with its full path location. how to do it? Thanks in advance
How to read the contents in a file which is of input type file
How to read the contents in a file which is of input type file  I...-data" ACTION="upload"> File to upload: <INPUT TYPE=FILE NAME="upfile"><BR> <INPUT TYPE=SUBMIT VALUE="Submit"> upload.java
Conversion from string data type into different data types.
Conversion from string data type into different data types.  string str="World id Beutifull"; char chr[20]; char* chrctr ; Qustion is -How to store the 'str' value in 'chr' and 'chrctr'? int abc; sprintf(abc ,"%s",str
input type checkbox HTML5,  input type radio HTML5.
input type checkbox HTML5,  input type radio HTML5. Introduction:In this tutorial, you will the use of  checkbox and radio type input field...;h2>Implementation of&nbsp; password type input tag. </h2> <
JDOM Attribute Example, How to convert value of attribute in different data type
JDOM Attribute Example, How to convert value of attribute in different data type In this tutorial, we will see how to retrieve the value of an attribute in different data type like int, float, boolean etc with the help of JDOM
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
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
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 - Java Beginners
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...:"); Scanner input=new Scanner(System.in); String name=input.nextLine
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 type dialog box take text and search a list and focus that text - JSP-Servlet
input type dialog box take text and search a list and focus that text  i have a button..when i press it will prompt a dialog box with a text box... then it will search a list which contains data in the same page and if found
java program of different shapes
java program of different shapes  pls help me to get the code of a java program of different shapes using menu
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... of a specific primitive type. A buffer is a linear, finite sequence
Java type casting
Java type casting  What is Downcasting
eraser type generics in java
eraser type generics in java  Explain eraser type generics in java with example
Java type casting
Java type casting  Can a Byte object be cast to a double value
How to Type in japanese in java Textfield?
How to Type in japanese in java Textfield?  Hello Sir/madam; Am creating an application in java in which i want to get a japanese String input from user.User needs to type in japanese in the textField.but I dont know how to type
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
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...); System.out.println("Type some numbers, " + "the last one being 0"); number
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
methods type - Java Beginners
methods type in Java  Give me an example programs of methods types in Java
Reference type Vs Object type. - Java Beginners
Reference type Vs Object type.  Can anyone explain the exact.... They never contain the object. C++ object variables may be either, but Java supports only object references. For Example : Book bookvar = new Book("Java
type casting - Java Beginners
type casting and conversion  I am beginner and my query is Importance of type casting and conversion  Hi friend,public class TypeCasting...://www.roseindia.net/java
Java Type Casting - Java Beginners
Java Type Casting  what is object type casting? give some example with related
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
Getting A File's Mime Type In Java
Getting A File's Mime Type In Java  Getting A File's Mime Type In Java
Type casting in java
Type casting in java In this section you will learn about type casting in java. Type casting is to convert one type to another type. Java support two types... a double type cast to int type    Reference type casting : In java type
Type Conversion - Java Beginners
Type Conversion   Hai, rajanikanth, Please explain how to convert from integer value to a string value .In a database operation i want to convert it.   hi jagadish Suppose int num = 10; String id = ""+num
How to print different Messge for the same NumberFormatException on different cause objects in JAVA?
How to print different Messge for the same NumberFormatException on different cause objects in JAVA?  How to print different Messge for the same NumberFormatException on different cause objects in JAVA? try { int
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 Boxes. Show the result with Message Dialog Boxes. Set the Message Dialog Box Type
different execution time - Java Beginners
different execution time    hello, when i run the bellow code more than one time i am getting different execution time("Total time taken"), Ex... java code therefore due to the execution of other many processes into the system
What type of programming language is Java?
What type of programming language is Java?  Hi, What type of programming language is Java? Why anyone should learn Java? What is Java and what features? Thanks   Hi, Java is Object Oriented, platform independent
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 get User Input
Java get User Input       In this section, you will learn how to get the user input from the command prompt. We are providing you a java application
Data type in java
Data type in java In this section we will tell you about data type in java. A data type is defined as " type of data that can be stored in variable". Java is a statically-typed language that means before using the variable
objective type question - Java Beginners
objective type question  Hi, Thakns for properly reply,I want to core java objective programming question plz let me url of this problem Thanks Ragini  You can find in www.javafaqs4u.com  
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 japanese character on frame and need to get the japanese string from
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
Set Different Color to different row in Java Program
Java Set Different Color to different row In this section, you will learn how to set different color to table row using java swing.For this purpose, we have.... This class provides the method setBackground() which allow us to set different
java type casting problem - Java Beginners
java type casting problem  what is type casting? what is the type of type casting? explain with example?  Hi Friend, Please visit the following link: http://www.roseindia.net/java/beginners/TypeCasting.shtml
object retun type - Java Beginners
object retun type  Hi, i have to create a method which should have return type of object . The object should contain 'list of filenames' array and a boolean field 'isVal'. Can anybody help
Date type typecasting - Java Beginners
Date type typecasting  Can i type cast Date object of java.util.* to java.sql.* Date Object? if so how? Refer to the following url http.... Date.parse gives you a result of type java.util.Date.Unfortunately for JDBC you need
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

Ads