从java中的文件获取输入时出错

时间:2014-10-25 05:27:37

标签: java

我有一个大小为10 ^ 6个元素的输入文件,我正在接受输入。

    Input File:
  100000 //size of the array
   2 3 4 (so on as large as 10^6) 5 6 99

代码:

 Scanner in = new Scanner(new FileReader("Input.txt"));
 int n = in.nextInt();
 int[] p = new int[n];
   for(int j=0;j<n;j++)
     p[j]=in.nextInt();  // line 90

错误:

Exception in thread "main" java.util.NoSuchElementException
    at java.util.Scanner.throwFor(Unknown Source)
    at java.util.Scanner.next(Unknown Source)
    at java.util.Scanner.nextInt(Unknown Source)
    at java.util.Scanner.nextInt(Unknown Source)
    at jobs.TestClass.main(TestClass.java:90)

请帮助我,我错了

0 个答案:

没有答案