Results 1 to 4 of 4
  1. #1
    jointhelabel is offline Member
    Join Date
    Oct 2008
    Posts
    1
    Rep Power
    0

    Default Multiple line user input

    I'm trying to write a program that accepts user input to find a particular file and perform a particular action. I can't seem to make it so that the user in Windows CMD can type multiple lines, like in a text file, rather than just one line at a time. I'd like to use readLine() or some equivalent after the user enters the information to read and disperse the various components, but i don't know if that's possible. This is the format of user input i need from the command prompt.

    GET \userinfo\scenario4.txt
    (blank line)
    additional optional data(could be any length)

    the blank line is an actual blank line. any help would be much appreciated.

  2. #2
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,321
    Rep Power
    25

    Default

    I'd like to use readLine()
    By definition readLine reads a line, not more than one line.
    When reading from console input, how will you detect the end of the user's input? If optional data follows a blank line, then the user will have to signal end of input for the program to recognize it.
    On some OSs there is a control key + letter combo to signal EOF.
    I think it's Ctrl+C on Windows but am not sure.

    To read more than one line, put the readLine() in a loop and continue reading until EOF is signalled.

  3. #3
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    I don't think in Windows command prompt you can enter multiple lines. I think Ctrl+C is the terminate command of e process, cannot use for EOF notification.

    Since readLine() read a line-by-line, you can read all information through a single line by use of a special character separation, may be a comma or any other characters. Then you can process it in your application before read the file and so on. Just a tip.

  4. #4
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,321
    Rep Power
    25

    Default

    Try CTRL+Z and Enter for EOF.
    Remember EOF will mean that you can NOT read any more from the console.

Similar Threads

  1. how to get input from User
    By Alvaro in forum New To Java
    Replies: 7
    Last Post: 01-15-2010, 11:02 PM
  2. who to take user input ,not by console...
    By Shyam Singh in forum New To Java
    Replies: 3
    Last Post: 06-13-2008, 10:09 PM
  3. Prompting user input of a string.
    By apfroggy0408 in forum New To Java
    Replies: 3
    Last Post: 03-09-2008, 06:23 PM
  4. cant take input from user
    By new_1 in forum New To Java
    Replies: 6
    Last Post: 12-25-2007, 07:38 AM
  5. Multiple Line Input Dialog Box
    By johnt in forum AWT / Swing
    Replies: 2
    Last Post: 05-31-2007, 09:30 PM

Posting Permissions

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