我试图通过命令行接受3个文件名。这是我尝试的代码,但不工作。?? 请帮助
public class MedicalStudentMatcher {
enum Arguments {
HospitalFile, ResidentFile, OutputFile
};
/**
* @param args
*/
public static void main(String[] args) {
//Retrieve file locations from command line arguments
String hospitalFile = "";
String residentFile = "";
String outFile = "";
if (args.length > 2){
hospitalFile = args[Arguments.HospitalFile.ordinal()];
residentFile = args[Arguments.ResidentFile.ordinal()];
outFile = args[Arguments.OutputFile.ordinal()];
} else {
System.out
.println("Please include names for the preference files and output file when running the application.n "
+ "Usage: ntjava MedicalStudentMatcher hospital.csv student.csv out.txtn");
return;
}
做一些调试。打印命令行参数的长度以及每个参数
类似于:
System.out.println(args.length);
for(String arg: args)
{
System.out.println(arg);
}