This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Suppling the name of the file

 
Arthur Zadrozny
Greenhorn
Posts: 3
  • 0
  • 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
  • 0
  • 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
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic