Results 1 to 8 of 8
- 02-07-2012, 09:55 PM #1
Member
- Join Date
- Feb 2012
- Posts
- 4
- Rep Power
- 0
files-input from console application
Hello,
I want the program to combine 2 txt files and create a new one. The thing is that I cannot find anywhere how to declare the files together with the app.
For example: java <name> -q <file1> -w <file> 2
How could this be done?
Is this even possible?
Thanks in advance.
- 02-07-2012, 10:01 PM #2
Re: files-input from console application
You can use the command line to pass any arguments to the program. What is passed is completely up to you.how to declare the files together with the app.
java <CLASSNAME> <any args that you want here>
To see what is passed and how to get it, write a simple program that prints out the args array that the main() method receives.
Then call it with a lot of different arguments and see what it prints out.
- 02-08-2012, 10:59 AM #3
Member
- Join Date
- Feb 2012
- Posts
- 4
- Rep Power
- 0
Re: files-input from console application
Thanks for this. I started with something...
...and I stuck again:
The compiler recognizes (args[0] = "-i") as String an not as boolean.( in an if (~))
Any ideas about what am I doing terribly wrong?
- 02-08-2012, 12:36 PM #4
Re: files-input from console application
The args from the command line are contained in the String array: main(String[] args)The compiler recognizes (args[0] = "-i") as String an not as boolean.
args[0] = "-i"
Is an assignment (=) statement. Use the equals() method for comparing Strings
- 02-08-2012, 12:51 PM #5
Member
- Join Date
- Feb 2012
- Posts
- 4
- Rep Power
- 0
Re: files-input from console application
:O I will try == and then the method you advised..
thanks.. It was really in front of me..
- 02-08-2012, 12:53 PM #6
Re: files-input from console application
Use the equals() method for Strings NOT ==
- 02-08-2012, 01:27 PM #7
Member
- Join Date
- Feb 2012
- Posts
- 4
- Rep Power
- 0
Re: files-input from console application
:O I will try == and then the method you advised..
thanks.. It was really in front of me..
- 02-08-2012, 02:53 PM #8
Similar Threads
-
Console input issue
By gaguevaras in forum New To JavaReplies: 3Last Post: 05-01-2011, 03:42 AM -
How to get input from Console
By karma in forum New To JavaReplies: 8Last Post: 08-13-2010, 09:32 PM -
how to take input from console in jsp
By veena in forum New To JavaReplies: 1Last Post: 05-06-2008, 04:39 AM -
How to read input from console
By Java Tip in forum java.ioReplies: 0Last Post: 04-16-2008, 10:57 PM -
How to read input from the console
By Java Tip in forum java.ioReplies: 0Last Post: 04-06-2008, 07:41 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks