用idea编写java,出现这种情况Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0at yecheng.Search.main(Search.java:18)Process finished with exit code 1源代码:public class Search {public static void main(String[] arg){MysqlDB db = new MysqlDB();Index index = new Index();ReadFile rf = new ReadFile();File file = new File(arg[0]);try {rf.readFile(file);index.loadDB(db);int id = index.search(rf.fingerprint,15);System.out.println(id);} catch (Exception e) {e.printStackTrace();System.out.println(e.toString());}}}
1 回答

慕丝7291255
TA贡献1859条经验 获得超6个赞
取值时,先看下String[] arg 这个数组里面有没有值,就是做一个判断,一般情况下可能是File file = new File(arg[0]); 这一步出错,就是 arg数组没有值,但是你取了。
加个if判断就行
添加回答
举报
0/150
提交
取消