Thread: Copying a File
View Single Post
Old 10-19-2012, 09:08 PM   PM User | #6
ubiByte
New to the CF scene

 
Join Date: Oct 2012
Posts: 5
Thanks: 1
Thanked 0 Times in 0 Posts
ubiByte is an unknown quantity at this point
Quote:
Originally Posted by Fou-Lu View Post
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
ubiByte is offline   Reply With Quote