ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Paul Perevalov" <ppereva...@cyber-asp.com>
Subject RE: keyboard I/O and Ant 1.4
Date Thu, 08 Nov 2001 15:15:40 GMT
I had same problem, but from <script> task using JavaScript.
The only way I found to access keyboard is to open file "con".
It works for me on Win2000.

Here is a piece of code on JavaScript:

<script language="javascript"> <![CDATA[
  importPackage(Packages.java.lang);
  importPackage(Packages.java.io);
  ....
  //get standart input stream
  var stdin = new BufferedReader(new InputStreamReader(new
FileInputStream("con")));
  System.out.println("Please enter password:");
  temp = stdin.readLine();
  project.setProperty("password",temp);
  ....
</script>

Paul Perevalov

-----Original Message-----
From: Michael Starkie [mailto:efficacy@my-deja.com]
Sent: Thursday, November 08, 2001 9:53 AM
To: ant-user@jakarta.apache.org
Subject: keyboard I/O and Ant 1.4


Ant version: 1.4

I have a block of java code of which I execute using the "Java" task which
attemps to read input from the keyboad and print the result.  The test works
fine when run outside of ant.  It seems like my keyboard has been cut-off
from my process somewhere even tho I set fork="no".

In the code below I have two print statements; "Before Read" and "After
Read".  The while loop should break when a user hits return.  The while-loop
breaks when run outside of Ant but it does not when called from Ant. Why
Not?

------------------------

    public static String getLine()
    {
        StringBuffer buf = new StringBuffer(80);
        int c;
        try
        {
            System.out.println("Before Read");

            while ( ( c = System.in.read() ) != -1)
            {
                char ch = (char) c;
                if (ch == '\n') break;
                buf.append(ch);
            }

            System.out.println("After Read");
        }
        catch ( IOException e)
        {
            System.err.println(e);
        }

        return ( buf.toString() );
    }



------------------------------------------------------------
--== Sent via Deja.com ==--
http://www.deja.com/

--
To unsubscribe, e-mail:   <mailto:ant-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-user-help@jakarta.apache.org>



--
To unsubscribe, e-mail:   <mailto:ant-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-user-help@jakarta.apache.org>


Mime
View raw message