This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
The moose likes Java in General and the fly likes Writing a Control file to give inputs to a Java application Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Writing a Control file to give inputs to a Java application" Watch "Writing a Control file to give inputs to a Java application" New topic
Author

Writing a Control file to give inputs to a Java application

Jujhar Khurana
Greenhorn

Joined: Dec 01, 2012
Posts: 11
Dear Ranchers !
I need your help again. I have developed a java application with no GUI. It takes input from command line and runs a set of functions and returns output ( a .csv file ) after querying a dataset (.csv file).
My supervisor wants me to found out a way to write a sort of Control File in which we can write all the inputs and then run it.

Is there a way to do it ?
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18150
    
    8

Of course. Make a file which contains exactly what you would have typed at the command line, and then run your application with that file redirected to standard input.

So normally you would run the application like this:

java YourClass


or maybe something a bit more complicated than that, but let's just use that as an example. This will expect you to type the input at the command line. To provide input from a file, run the application like this:

java YourClass < control.txt


This will take the output from the "control.txt" file in the current working directory instead of expecting command-line input from you.

By the way this is a standard feature of the command line no matter whether it's the Windows command line or a *nix shell. It's nothing to do with Java, it works for all applications which read from standard input.
Jujhar Khurana
Greenhorn

Joined: Dec 01, 2012
Posts: 11
Thank You Paul. I appreciate.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Writing a Control file to give inputs to a Java application
 
Similar Threads
Nested for loops to the point of confusion
how to load a cvs file into a oracle 9i database using java
File validation after File Upload
How an XML document is written into CSV format in Java/JSP
Help Needed regarding reading the csv file