Quote:
Originally Posted by Fou-Lu
The main method signature in Java is only a string array.
To prevent out of bound exceptions, you can either try/catch them or simply verify the length first:
PHP Code:
public static void main(String[] argv)
{
if (argv.length != 2)
{
System.out.println("Incorrect command line call of application.");
}
else
{
String sOriginating = argv[0];
String sDestination = argv[1];
// copy stuff here.
}
}
|
I can't get this to work I'm getting pretty frustrated, in the main am i supposed to use the constructor to create a file because if i do my constructer is already copying a file.
Do i do something like this:
Code:
FileCopy copier = new FileCopy(srcFileName, dstFileName);
if (args.length != 3)
{
System.out.println("Incorrect command line call of application.");
}
else
{
String to = "to";
srcFileName = args[0];
to = args[1];
dstFileName = args[2];
}
Sorry I've just never done anything with the command prompt no idea how to make it work