java - how do you input from the command line
i'm kinda perplexed, i've got a project for school where we're supposed to write a driver to allow piped input/output : for ex, driver < inputFile1 > outputFile but for a variety of input files. i can't figure out how to code this without specifically including the input file in the driver. can anyone help?
|
no worries, got it figured out.
|
The answer to the question is to use the System.in and System.out streams.
Please post the answers to your questions if you find out what they are; that way other people can benefit from your insight. Well done on fixing it, though :) |
I think zeviddalop meant take arguments when calling 'java' to exec the program. If that is the case, it is almost like C++:
class App { public static void main(String[] args) { //all command line arguments are stored in 'args'; just use it like a normal array //(the exec name isn't given in [0], unlike C++) } } |
If i were to read by lines, I would do:
Code:
BufferedReader keyboard = new BufferedReader(new InputStreamReader(System.in)); |
All times are GMT -5. The time now is 04:59 AM. |