Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
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 11-02-2007, 11:50 PM
gvi gvi is offline
Member
 
Join Date: Oct 2007
Posts: 6
gvi is on a distinguished road
Running java program with arguments in Unix"
Hi
I am a new newbie to java so pardon if this is too simple for you .

This is my scenario. I have a java program which parses an xml and writes a .dat file. I execute this testparser.java in unix environment like this

java testparser xml1.xml

and it retuns me a .dat file

But my issue is I have to run my parser program for 40 xml files. The requirement is I have to create a script file and possibly with a for loop which will loop through 1-40 xml files and return me the .dat file.

I am really at a loss here. I am new both to Java and Unix

So pls help me out

Thanks in Advance
G
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 11-03-2007, 08:32 AM
JavaBean's Avatar
Moderator
 
Join Date: May 2007
Posts: 1,272
JavaBean is on a distinguished road
What about creating a text file which will have your xml files listed in separate lines. As far as i understand your problem, you can modify your program to get this .txt file as an input and loop for all these xml files to generate dat file(s).
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 11-08-2007, 08:01 PM
Member
 
Join Date: Nov 2007
Location: Singapore
Posts: 3
made.putrama is on a distinguished road
You may try the following code:

Code:
public class TestParser{ public static void main(String[] args){ for(int i=0; i<Integer.parseInt(args[1]); i++) { File file = new File(args[0]+"/filename"+(i+1)+".xml"); doTestParser(file); } } static void doTestParser(File pFile ){ //do something with the xml file } }

You should now execute only one time from the command line, e.g:

/>java Testparser <<file directory>> <<total file>>


Regards,
Putrama
__________________

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
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
Accessing unix system using java abhishek.sinha AWT / Swing 3 06-19-2008 09:05 AM
how to run java app on windows in a cron like on unix rockie12 Advanced Java 7 05-23-2008 02:39 PM
When to use –client and -server option while running a java program Java Tip java.lang 0 04-04-2008 03:49 PM
Filter a file in java (unix cut command equivalent) marcosabel New To Java 0 02-11-2008 08:26 PM
Call a main method from within a running program zoe New To Java 1 08-07-2007 07:16 AM


All times are GMT +3. The time now is 05:21 PM.


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