Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Linux Archive
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 02-15-2008, 06:41 AM
Member
 
Join Date: Feb 2008
Posts: 2
vipvan2000 is on a distinguished road
Parsing Argument Values
We use command line scripts to pass values like

java submit <input_file=test1> <output_dir=dir_name>

I have a need to pass the argument values to another program. How do I parse these values.
Sorry if it was asked earlier but I am very new to Java.

Thanks in advance
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 03-06-2008, 01:01 PM
Member
 
Join Date: Nov 2007
Posts: 11
rajiv_bang is on a distinguished road
Hi,

You can improve the code below and use. This is just indicative.

Code:
public class ParseOptions { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub String input_file = args[0].split("=")[1]; String dest_dir = args[1].split("=")[1]; System.out.println("input_file "+input_file); System.out.println("dest_dir "+dest_dir); } }
But an elegant way to do this would be to use one of the open source command line frameworks like Apache Commons.

HTH
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Command line argument denisatandi New To Java 3 06-15-2008 08:59 AM
Accessing boolean Values of another values in one class. a_iyer20 Advanced Java 4 04-15-2008 03:04 PM
How to resolve Constructor argument in Spring Java Tip Java Tips 0 03-29-2008 02:43 PM
Parsing Argument Values vipvan2000 Advanced Java 1 02-17-2008 03:41 AM
How to resolve Constructor argument in Spring JavaBean Java Tips 0 09-26-2007 10:34 PM


All times are GMT +3. The time now is 04:37 AM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org