Mr. Sarkar's Outdated Computer Science Blog
To go to the updated website, go to: westhillcs.com
Friday, March 13, 2015
How to pass a filename to a program
The code below assumes that the filename to be used by the progam is contained in args[0]
public class FileNameDemo
{
public static void main(String [] args) {
String fileName = args[0];
FileReader reader = new FileReader(fileName);
Scanner inputFile = new Scanner(reader);
}
}
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment