|
-
March 6th, 2000, 03:57 AM
#1
command line arguments (String args[])
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
([email protected])
-
March 7th, 2000, 11:13 AM
#2
Re: command line arguments (String args[])
Hi there,
if(args.length>0){
//This means that arguments have been sent
}
else {
//This means that no arguments have been sent
}
Greets,
Jan Meeuwesen
( If this is the answer your looking for, rate this post!! (Bottom right under this text) )
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|