?
Solved

implementing Option handling : command line exception

Posted on 2004-09-06
5
Medium Priority
?
255 Views
Last Modified: 2010-03-31
Hi experts

I want to create a program that gets arguments from command line, and I would like to check for exceptions.

public static void main( args[] )
{
.......
}

for example,
All arguments must be int , or all must be between 'a' to 'z'.
The number of arguments must be 5, and 5th argument must be bigger than 4th, and so on.....
is there any ready made option handling class i can use?
I would appreciate if some one can show me some example code.
thanx

0
Comment
Question by:oldb
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 18

Accepted Solution

by:
armoghan earned 100 total points
ID: 11993954
0
 
LVL 92

Expert Comment

by:objects
ID: 11993968
0
 
LVL 18

Expert Comment

by:armoghan
ID: 11994221
For getting integer use
int firstArg;
firstArg = Integer.parseInt(args[0]);

for text having only alphabets use this function

public static boolean isLetter(String s)
{
for(int i = 0; i < s.length(); i++)
{
if(!Character.isLetter(s.charAt(i)))
{
return false;
}
}

return true;
}
 
0
 
LVL 18

Expert Comment

by:armoghan
ID: 12041712
Thanx.
But can you pleae tell me the reason to give it a C grade?
0

Featured Post

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
Suggested Courses

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question