Solved

implementing Option handling : command line exception

Posted on 2004-09-06
5
207 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
  • 3
  • 2
5 Comments
 
LVL 92

Expert Comment

by:objects
ID: 11993889
0
 
LVL 18

Accepted Solution

by:
armoghan earned 50 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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
copyEndy  challenge 15 58
network + 7 73
strDist challenge 35 84
VB Script to add site to Java Exception List 4 18
For customizing the look of your lightweight component and making it look opaque like it was made of plastic.  This tip assumes your component to be of rectangular shape and completely opaque.   (CODE)
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 …
The viewer will learn how to implement Singleton Design Pattern in Java.
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

743 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now