different type input in java

Ads
 

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);
            }
}

Ads









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
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
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
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
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
eraser type generics in java
eraser type generics in java  Explain eraser type generics in java with example
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 type casting
Java type casting  Can a Byte object be cast to a double value
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
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
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
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
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 / 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
Getting A File's Mime Type In Java
Getting A File's Mime Type In Java  Getting A File's Mime Type In Java
input
input  a java program that will exchange the last names of two students that were input by a user
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> <
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
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
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
Data type in java
Data type in java In this section we will tell you about data type in java... type of data, which has an initial value 1. There are two data type in java... :  Apart from int type there are seven other primitive data types in java
different output trying to execute same java code
different output trying to execute same java code  i am using net beans 7 ide and java 6 to develop my java projects. i used the following coding... there is different output trying to execute same java code
java- jdbc with type 4 driver
java- jdbc with type 4 driver  My program code is----- import java.sql.*; import java.lang.* ; import java .io.*; import java.util.*; import...*; import java.lang.* ; import java .io.*; import java.util.*; import
different output trying to execute same java code
different output trying to execute same java code  i am using net beans 7 ide and java 6 to develop my java projects. i used the following coding... " portList : false" Why there is different output trying to execute same java
different output trying to execute same java code
different output trying to execute same java code  i am using net beans 7 ide and java 6 to develop my java projects. i used the following coding... " portList : false" Why there is different output trying to execute same java
java code that monitors the mic input, and dims the screen accordingly
java code that monitors the mic input, and dims the screen accordingly  I know the very basic syntax of java, could someone help me write a code... this could run in the background for a few hours and be run on a different computer
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
java code to validate column content of 2 different tables in 2 different databases.
java code to validate column content of 2 different tables in 2 different... at different server and display output( in excel format) using JAVA. if matched... that the migrated data is correct by creatng a script to run written in java

Ads