command line interface


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 4 of 4

Thread: command line interface

Hybrid View

  1. #1
    Artemis Guest

    command line interface


    i'm pretty new at this java thing and i was wondering if someone would be
    kind enough to help me out...my question is how do you get user input from
    a command line interface? should i be using the console reader? it seems
    that i'm having problems reading strings and i'm not sure what to do. any
    suggestions? thanks!

  2. #2
    Nick Guest

    Re: command line interface


    Hi,
    You can use BufferedReader screen = new BufferedReader(new InputStreamReader(System.in,
    true));
    Delcare the item as static and use it in your class(driver file, etc).
    This is how we did it my Java classes.

    Hope this helps.
    Nick





    "Artemis" <OutGirl25@hotmail.com> wrote:
    >
    >i'm pretty new at this java thing and i was wondering if someone would be
    >kind enough to help me out...my question is how do you get user input from
    >a command line interface? should i be using the console reader? it seems
    >that i'm having problems reading strings and i'm not sure what to do. any
    >suggestions? thanks!



  3. #3
    Nick Guest

    Re: command line interface


    One note, I can't remember if the second parameter for InputStreamReader is
    necessary. If it gives you problems, try omitting it.

    Nick





    "Artemis" <OutGirl25@hotmail.com> wrote:
    >
    >i'm pretty new at this java thing and i was wondering if someone would be
    >kind enough to help me out...my question is how do you get user input from
    >a command line interface? should i be using the console reader? it seems
    >that i'm having problems reading strings and i'm not sure what to do. any
    >suggestions? thanks!



  4. #4
    Rajkamal Gopinath Guest

    Re: command line interface


    Hi

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

    String s=cin.readLine();

    or

    DataInputStream cin=new DataInputStream(System.in);

    String s=cin.readLine();

    but readLine method in DataInputStream is deprecated

    Regards

    Raj


    "Nick" <ned1972@hotmail.com> wrote:
    >
    >One note, I can't remember if the second parameter for InputStreamReader

    is
    >necessary. If it gives you problems, try omitting it.
    >
    >Nick
    >
    >
    >
    >
    >
    >"Artemis" <OutGirl25@hotmail.com> wrote:
    >>
    >>i'm pretty new at this java thing and i was wondering if someone would

    be
    >>kind enough to help me out...my question is how do you get user input from
    >>a command line interface? should i be using the console reader? it seems
    >>that i'm having problems reading strings and i'm not sure what to do. any
    >>suggestions? thanks!

    >



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center