Reputation: 604
I came across the following code in a book recently. It says that we can reference a file for instance that we want to read by writing a command line like the first line below. However it is throwing an error with this line. Can someone please advise as I have never come across this before?
Thanks
java ShowFile c:/Users/Bosra/Desktop/Sample.txt
import java.io.*;
public class ShowFile
{
public static void main(String args[])
{
int i;
FileInputStream fin;
//first confirm that a filename has been specified
if(args.length!=1)
{
System.out.println("Usage:ShowFile Filename");
return;
}
}
}
Upvotes: 0
Views: 246
Reputation: 2340
The first line is the thing you should type in at the command line after compiling the file - it doesn't belong in the file itself.
Upvotes: 3