Console Class

Various command line utilities used to print debug messages and collect user inputs.

Constructors

There are no public constructors.

Properties

console
Static instance of the this class that can be called directly via a static import. Example:
    import static javaxt.utils.Console.console;
    public class Test {
        public Test(){
            console.log("Hello!");
        }
    }    

Public Methods

log( Object... any ) returns void
Prints a message to the standard output stream, along with the class name and line number where the log() function is called. This function is intended to help debug applications and is inspired by the JavaScript console.log() function.
anyAccepts any Java object (e.g. string, number, null, classes, arrays, etc). You can pass in multiple objects separated by a comma. Example:
       console.log("Hello");
       console.log("Date: ", new Date());
       console.log(1>0, 20/5, new int[]{1,2,3});    

Static Methods

getInput( String prompt ) returns String
Used to prompt a user for an input
getUserName( String prompt ) returns String
Used to prompt a user for a username
getPassword( String prompt ) returns String
Used to prompt a user for a password. The password is hidden as is it entered.
parseArgs( String[] args ) returns HashMap<String, String>
Converts command line inputs into key/value pairs. Assumes keys start with a "-" character (e.g. "-version" or "--version") followed by a value (or nothing at all).
getValue( HashMap<String, String> args, String ...keys ) returns Value
Returns a value for a given set of command line arguments
argsHashMap of command line inputs generated by parseArgs()
...keys
main( String[] args ) returns void
Used to print the JavaXT version number when this jar is called from the command line. Example:
    java -jar javaxt-core.jar
    JavaXT: 1.11.3    
Under the hood, this simple command line application uses the getVersion() method in the javaxt.io.Jar class.