Java程序不能读取超过64116个文件,并抛出一个没有stacktrace的异常

Java程序不能读取超过64116个文件,并抛出一个没有stacktrace的异常,java,eclipse,ubuntu-14.04,indexoutofboundsexception,printstacktrace,Java,Eclipse,Ubuntu 14.04,Indexoutofboundsexception,Printstacktrace,我对JAVA相当陌生(就像它看起来一样)。我使用eclipse编写了一个程序来读取大约150k个文件,然后将每个文件的内容打印到控制台 有趣的是(至少对我来说),在读取64116个文件后,程序抛出一个ArrayIndexOutOfBoundException,没有任何StackTrace。我试图手动捕获异常并找出异常的原因,但它返回null。 还有,我试着打电话 System.gc() 为了获得空闲内存,以防它被对象重载,但没有运气。 我正在使用 -64位 -16GB内存 -Core

我对JAVA相当陌生(就像它看起来一样)。我使用eclipse编写了一个程序来读取大约150k个文件,然后将每个文件的内容打印到控制台

有趣的是(至少对我来说),在读取64116个文件后,程序抛出一个ArrayIndexOutOfBoundException,没有任何StackTrace。我试图手动捕获异常并找出异常的原因,但它返回null。 还有,我试着打电话

   System.gc() 
为了获得空闲内存,以防它被对象重载,但没有运气。

我正在使用 -64位 -16GB内存 -Core-i7-3.60GHz -Ubuntu 14.04 -EclipseIDE -OpenJDK-7

这是我正在运行的代码-

  try {
        for(File file : fileList){
            String fileName = file.getPath();
            ExtractorFromFile extr = new ExtractorFromFile();
            DemoClass obj = extr.extract(fileName);
            Map<String, Integer> wordListforCurrent = obj.uniqueWordList();
            for (Map.Entry<String, Integer> entry : wordListforCurrent.entrySet()) {
                String key = entry.getKey();
                Integer value = entry.getValue();
                if( !universalWordList.containsKey( entry.getKey() ) ){
                    universalWordList.put(key, 1);
                }
                else {
                    Integer newVal = universalWordList.get(key);
                    newVal++;
                    universalWordList.put(key, newVal);
                }
            }
            count ++;

            if(count == 50000){
                System.gc();
                //break;
            }
        }           
    }catch(Exception e){
        System.out.println("Count:" +count);
        System.out.println(e.getCause());
        e.printStackTrace();
    }
有人能告诉我我做错了什么吗?如何使用JAVA读取任意数量的文本文件而不出现任何错误或异常?我从未编辑过任何JVM配置文件。因此,如果涉及到编辑JVM配置,我将非常感谢您提供的一个逐步建议


谢谢大家抽出时间

你快用完了。谢谢你的快速回复。如何不耗尽文件句柄?您没有显示的
extract()
的实现在返回之前没有关闭文件。我已尝试将ulimit设置为1000000,但它不起作用@mikesamuel删除对任何未检查异常的捕获,就像您通常只捕获异常一样。让它失败并打印带有行信息的堆栈跟踪。
    public Test extract(String fileName) {
    // TODO Auto-generated constructor stub
    Test test = new Test();

    try {
        // FileReader reads text files in the default encoding.
        FileReader fileReader = 
            new FileReader(fileName);

        // Always wrap FileReader in BufferedReader.
        BufferedReader bufferedReader = 
            new BufferedReader(fileReader);

        while((line = bufferedReader.readLine()) != null) {
            //System.out.println(line);
            //some String processing here
        }

        // Always close files.
        bufferedReader.close();         
    }
    catch(FileNotFoundException ex) {
        System.out.println(
            "Unable to open file '" + 
            fileName + "'");                
    }
    catch(IOException ex) {
        System.out.println(
            "Error reading file '" 
            + fileName + "'");                  
        // Or we could just do this: 
        // ex.printStackTrace();
    }
    return test;
}