public class NewClass1 {
public static void main(String[] args) throws FileNotFoundException {
String datasetFile = args[0];
BufferedReader in = new BufferedReader(new FileReader(datasetFile));
}
}
它生成以下錯誤我想進入一個命令行參數爲我的字符串
Exception in thread "main" java.io.FileNotFoundException: abc (The system cannot find the file specified)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(FileInputStream.java:138)
at java.io.FileInputStream.<init>(FileInputStream.java:97)
at java.io.FileReader.<init>(FileReader.java:58)
at JavaApplication.NewClass1.main(NewClass1.java:29)
我應該與此代碼代替它呢?
BufferedReader out = new BufferedReader(new
InputStreamReader(System.in));
String input = out.readLine();
此鏈接可能會有幫助:http://users.cms.caltech.edu/~donnie/cs11/java/java-main.html –
謝謝你的鏈接是有幫助的 –
不客氣:) –