Results 1 to 2 of 2

Thread: How to automate user inputs...

  1. #1
    Contributing Member
    Join Date
    Sep 2006
    Answers
    962

    How to automate user inputs...

    We have a Java program which prompts user for 4 or 5 inputs one after the other and then does its computation. The inputs are mostly file names and folder paths. I am trying to figure out a way of automating these inputs. We don't want to (and can not) change the program to read inputs from a file. We only have class files for the program with us.

    Is there any way i can automate these user inputs. Say for instance, the inputs would be specified in a text file beforehand and would be read by the java program on each prompt. May be it will require some batch or shell scripting. I am not sure though.

    Can someone give some inputs?


  2. #2
    Contributing Member
    Join Date
    Sep 2006
    Answers
    962

    Re: How to automate user inputs...

    For most programs we can make the input come from a file at the command line:

    java MyClass <filename.ext

    The left arrow tells the OS to feed whatever source follows into stdin of the program. See if that does the trick!

    The program should read the file one line at a time just as if the user was typing one response at a time. The newline in the file acts just like the enter key for the user. Make your own simple program that just reads lines from stdin and see how it behaves with different files.

    --------------------
    suresh


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
About us
Applying for a job can be a stressful and frustrating experience, especially for someone who has never done it before. Considering that you are competing for the position with a at least a dozen other applicants, it is imperative that you thoroughly prepare for the job interview, in order to stand a good chance of getting hired. That's where GeekInterview can help.
Interact