March 6th, 2000, 02:57 AM
I was wondering if anyone knows the default value of the String args[]
array passed to the main method if no command line arguments are entered.
For example, how would you test if there are no command line arguments?
public static void main( String args[] )
{
if( NO ARGS )
/* OUTPUT ERROR MESSAGE
I've tried:
if( args[0].equals("") ) // empty string
if( args[0].equals("\0") ) // NULL character
if( args[0].equals(null) )
if( args[0].length() < 1 ) // length = 0
NONE of these seem to do anything, and I get an error at runtime */
else // DO SOMETHING WITH THE ARGUMENTS
}
Eventually, there will be 2 arguments: an input filename and an output filename.
I need to convert the input file into all uppercase letters and send it to the output
file, but for now I am just trying to see how the arguments are handled before I
try anything more complicated.
I would appreciate if anyone who answers this post also sends a copy to my
personal email address as well.
Thanks
Tony Kom
(kom6188@cs.uidaho.edu)
array passed to the main method if no command line arguments are entered.
For example, how would you test if there are no command line arguments?
public static void main( String args[] )
{
if( NO ARGS )
/* OUTPUT ERROR MESSAGE
I've tried:
if( args[0].equals("") ) // empty string
if( args[0].equals("\0") ) // NULL character
if( args[0].equals(null) )
if( args[0].length() < 1 ) // length = 0
NONE of these seem to do anything, and I get an error at runtime */
else // DO SOMETHING WITH THE ARGUMENTS
}
Eventually, there will be 2 arguments: an input filename and an output filename.
I need to convert the input file into all uppercase letters and send it to the output
file, but for now I am just trying to see how the arguments are handled before I
try anything more complicated.
I would appreciate if anyone who answers this post also sends a copy to my
personal email address as well.
Thanks
Tony Kom
(kom6188@cs.uidaho.edu)