Opening a file after typing its name from command line?

OK it's been a real long while since I did any Java hacking, how can I do this again?

Here's some source I have from a book.

//ReadTextFile.java

// open the text file

import java.io.File;

import java.io.FileNotFoundException;

import java.lang.IllegalStateException;

import java.util.NoSuchElementException;

import java.util.Scanner;

public class ReadTextFile

{

private Scanner input;

// enable user to open file

public void openFile()

{

try

{

input = new Scanner ( new File ("myfile.txt"));

} //end try

catch ( FileNotFoundException fileNotFoundException )

{

System.err.println( "Error opening file.");

System.exit(1);

} // end catch

} // end method openFile

// read records from file

public void readRecords()

{

int callID;

try

{

while (input.hasNext() )

{

callID = input.nextInt();

System.out.println(callID);

} // end while

} //end try

catch ( NoSuchElementException elementException )

{

System.err.println ("File improperly formed.");

input.close();

System.exit(1);

} // end catch

catch ( IllegalStateException stateException )

{

System.err.println ("Error reading from file." );

System.exit(1);

} // end catch

} // end method readRecords

// close file and terminate app

public void closeFile()

{

if (input != null )

input.close();// close file

} // end method closeFile

} // end class ReadTextFile

//ReadTextFileTest.java

public class ReadTextFileTest

{

public static void main( String args[] )

{

ReadTextFile application = new ReadTextFile();

application.openFile();

application.readRecords();

application.closeFile();

} // end main

} // end class

So at the command line I wanna do "java ReadTextFileTest openthisfile.txt" or whatever and have it open and read in some stuff from that file instead of hard coding it into the input = new Scanner ( new File ("myfile.txt")); line in the ReadTextFile.java

I'm sure it's pretty simple but like I said, very rusty.

[2286 byte] By [JW1969a] at [2007-11-27 8:28:49]
# 1
In main, args[0] is the first argument after the class name.
jverda at 2007-7-12 20:18:54 > top of Java-index,Java Essentials,New To Java...
# 2
Yeah I figured it out by just passing args[0] into the openFile method. I dunno what was wrong with my brain yesterday, I was typing arg[0] instead of args[0] and not seeing it. One of those days.
JW1969a at 2007-7-12 20:18:55 > top of Java-index,Java Essentials,New To Java...