Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

implementing Option handling : command line exception

Posted on 2004-09-06
5
Medium Priority
?
261 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
Suggested Courses

636 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