File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Read the name of the input file from cl

 
David McHugh
Greenhorn
Posts: 23
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,

i have to input a simple text file called text1.txt into my program called Input1.java, but i cannot code the filename into program e.g.

FileInputStream f;
try {
f = new FileInputStream("text1.txt");

i have to take it from the cl, e.g. when running the program type java Input1 text1.txt

any ideas?
 
Satish Chilukuri
Ranch Hand
Posts: 266
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Command line args
 
David McHugh
Greenhorn
Posts: 23
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
cheers satish
 
Nitesh Kant
Bartender
Posts: 1638
IntelliJ IDE Java MySQL Database
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just to make you aware. For any medium scale application, handling command line arguments become a bit troublesome specially when it comes to maintenance.

Libraries like Apache Commons CLI makes your life easy.
Needless to say, this is *only* required if you have (or expect to have) extensive command line options and will be an overkill for less command line options.
[ November 12, 2008: Message edited by: Nitesh Kant ]
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic