Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Suppling the name of the file

 
Arthur Zadrozny
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I am new here and I have question which might seem a little easy. I am writting a program which reads in a text file and the user needs to supply the name of that text file. How do I do that? Here is some code that might help. Thanks.
final static String FIRST_FILE = "the_open_window.txt";
public static void main (String [] args)
{
try {
Reader r = new BufferedReader (new FileReader(FIRST_FILE));
 
Michael Morris
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Arthur,

So if the name of your application is ReadSomeFile then the user might open start the application like:
java ReadSomeFile foo.txt
and the application should attempt to open the file named foo.txt in the current directory.
Hope this helps,
Michael Morris
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic