Results 1 to 6 of 6
  1. #1
    ashwin kumar is offline Member
    Join Date
    Jun 2011
    Posts
    6
    Rep Power
    0

    Default reading data from keyboard

    can someone explain me how to define methods for reading data from keyboard..all answers will be appreciated

  2. #2
    java_no1 is offline Member
    Join Date
    May 2011
    Location
    Bengaluru
    Posts
    14
    Rep Power
    0

    Default

    Hi ashwin kumar.
    You want to read data for Console or GUI????

  3. #3
    ashwin kumar is offline Member
    Join Date
    Jun 2011
    Posts
    6
    Rep Power
    0

    Default

    console firstly

  4. #4
    java_no1 is offline Member
    Join Date
    May 2011
    Location
    Bengaluru
    Posts
    14
    Rep Power
    0

    Default

    import java.io.*;


    class ReadLine{
    public static void main(String[] args) throws IOException{
    String CurLine = ""; // Line read from standard in

    System.out.println("Enter a line of text (type 'quit' to exit): ");
    InputStreamReader converter = new InputStreamReader(System.in);
    BufferedReader in = new BufferedReader(converter);


    while (!(CurLine.equals("quit"))){
    CurLine = in.readLine();

    if (!(CurLine.equals("quit"))){
    System.out.println("You typed: " + CurLine);
    }
    }
    }
    }

  5. #5
    ashwin kumar is offline Member
    Join Date
    Jun 2011
    Posts
    6
    Rep Power
    0

    Default

    unale to understand?????

  6. #6
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,883
    Rep Power
    25

    Default

    Another way to read from the console is with the Scanner class. Search this forum for many examples.

Similar Threads

  1. Reading Chunks of Data
    By icu222much in forum New To Java
    Replies: 3
    Last Post: 03-22-2010, 09:42 AM
  2. Replies: 5
    Last Post: 08-21-2009, 12:03 PM
  3. Reading Keyboard
    By ushigley in forum New To Java
    Replies: 4
    Last Post: 08-20-2008, 02:50 PM
  4. Reading Data from a file
    By ramachandran in forum New To Java
    Replies: 2
    Last Post: 10-24-2007, 08:22 AM
  5. Reading FileInput data
    By Eric in forum Advanced Java
    Replies: 1
    Last Post: 07-05-2007, 07:59 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •