Home ยป Apache Ant InputHandler

Apache Ant InputHandler

by Online Tutorials Library

Apache Ant InputHandler

Ant InputHandler is an interface which helps to a task to read user input. It is handy for any task to read user input from console or prompt for user input.

Task creates an InputRequest object and passes to InputHandler. InputRequest check the given input is valid or not and InputHandler can reject any invalid input.

This interface contains a method handleInput having the below signature.

This method throws a BuildException and does not allow to return any invalid request.

InputHandler Built-in implementation

  • DefaultInputHandler
  • PropertyFileInputHandler
  • GreedyInputHandler
  • SecureInputHandler


This is default implementation in case user does not use the -inputhandler command line option. It will prompt for the input in the request object and re-prompt until user enter valid input. This input will be read from console and the user will need to press the return key.


This is not default implementation and used to read user input from a property file. It returns exception and if input is not valid input. The name of the properties file must be specified in the Java system property ant.input.properties.

Note The property file must be a Java system property, not an Ant property.


This implementation reads from standard input and useful for sending Ant input via an OS pipe.


It acts as default handler except it uses System.console().readPassword() method to read user input from the console. Method was introduced in Java 6.

You may also like