Compress directory to tar.gz with Commons Compress

后端 未结 6 1404
终归单人心
终归单人心 2020-12-30 06:13

I\'m running into a problem using the commons compress library to create a tar.gz of a directory. I have a directory structure that is as follows.

parent/
          


        
6条回答
  •  盖世英雄少女心
    2020-12-30 06:52

    I followed this solution and it worked until I was processing a larger set of files and it randomly crashes after processing 15000 - 16000 files. the following line is leaking file handlers:

    IOUtils.copy(new FileInputStream(f), tOut);
    

    and the code crashed with a "Too many open files" error at the OS level The following minor change fix the problem:

    FileInputStream in = new FileInputStream(f);
    IOUtils.copy(in, tOut);
    in.close();
    

提交回复
热议问题