java.lang.OutOfMemoryError while transforming XML in a huge directory

后端 未结 4 1310
闹比i
闹比i 2021-01-05 19:58

I want to transform XML files using XSLT2, in a huge directory with a lot of levels. There are more than 1 million files, each file is 4 to 10 kB. After a while I always rec

4条回答
  •  甜味超标
    2021-01-05 20:28

    Try this one

    String[] files = dir.list();
    for (String fileName : files) {
        File file = new File(fileName);
        if (file.isDirectory()) {
            pushDocuments(file);
        } else {
            indexFiles.index(file);
        }
    }
    

提交回复
热议问题