Reputation: 27628
I can not get the difference between these sentences! would you please write some snippet code for these sentences?thanks
Upvotes: 0
Views: 234
Reputation: 114757
Imagine a command line copy program that you use like that:
copy <destination-dir> <source-file>
A simple implementation in Java would be (provided as a fragment):
package com.example;
import java.io.File;
public class Copy {
public static void main(String[] args) {
if (args.length != 2) {
exitWithErrorCode(); // to be implemented
}
File destinationDir = new File(args[0]);
File sourceFile = new File(args[1]);
copyFileToDir(sourceFile, destinationDir);
}
private static void copyFileToDir(File sourceFile, File destDir) {
// to be implemented
}
}
and you would call it like
java com.example.Copy /tmp /home/me/example.txt
Upvotes: 1
Reputation: 413682
It means that the program will be run like this:
java some.package.YourProgram /some/directory /some/file/name
Upvotes: 0
Reputation: 70108
It's as simple as that:
public static void main(String[] args)
{
// args[0] is the directory path
// args[1] is the file path
}
So what don't you understand?
Upvotes: 1