我有一個從文件中讀取,並存儲在一個鏈表中的內容,然後寫鏈表到另一個文件的內容的節目,以命令提示符工作執行Java程序
我有三個類: 1-代理(主類) 2-國家 3-鏈表
的CALSS劑的含量是:
public class Agent{
public static void main(String[] args) {
int n_args = args.length;
if (n_args!=4) {
System.out.println("ERROR: ILLEGAL NUMBER OF ARGUMENTS.");
System.out.println("Number of arguments must be 4");
return;
}
String mapFile = args[0];
String commandsFile = args[1];
String finalMapFile = args[2];
String logFile = args[3];
State s = new State();
s.read(args[0]);
s.read2(args[1]);
s.Action();
s.writemap(args[2]);
s.write(args[3]);
}
}
所有我需要他們的方法是班上國家 所以我創建國家 的對象,然後我做了所有的工作 但問題是,當我從命令提示符下執行它,當我寫這篇文章:
Ç :\用戶\教授\桌面\編譯> javac的Agent.java
我得到這個消息:
Agent.java:27:錯誤:未報告的異常IOException異常;必須捕獲或聲明拋出
s.read(args[0]);
^
Agent.java:28: error: unreported exception IOException; must be caught or declared to be thrown
s.read2(args[1]);
^
Agent.java:30: error: unreported exception UnsupportedEncodingException; must be caught or declared to be thrown
s.writemap(args[2]);
^
Agent.java:31: error: unreported exception UnsupportedEncodingException; must be caught or declared to be thrown
s.write(args[3]);
^
4 errors
我希望我的工作方案如下所示:
java Agent mapFile.txt commandsLine.txt finalMap.txt logFile.txt
任何幫助嗎?
你是否理解'compiling'和'execution'之間的區別?你的程序目前不能編譯,錯誤信息告訴你爲什麼。 –