Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Difrence in Input methods?
Index -> Programming, Java -> Java Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Jonny Tight Lips




PostPosted: Mon Aug 01, 2005 10:33 pm   Post subject: Difrence in Input methods?

I've foud two different ways to get data from a keyboard and I was wonding what the difference is.

First
code:

import java.io.*;

public class Test {
        public static void main(String [] args) {
        BufferedReader in;
        PrintStream out;
        String my_string;       
        try {


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

                my_string = in.readLine();
                out.println(my_string);

                my_string = in.readLine();
                out.println(my_string);
                }
        catch (IOException e) {       
                }       
        }
}


and second
code:

import java.io.*;

public class Test {
        public static void main(String [] args) {

        DataInput keyboard = new DataInputStream(System.in);
        String Input;   
        try {
                Input = keyboard.readLine( );
                System.out.println("You typed "+ Input);
                }
        catch (IOException e) {       
                }       
        }
}
Sponsor
Sponsor
Sponsor
sponsor
Display posts from previous:   
   Index -> Programming, Java -> Java Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 1 Posts ]
Jump to:   


Style:  
Search: