How to locally download a .tar.gz file on the server created using TarArchiveOutputStream

308 views Asked by At

I am using the owner accepted best answer in Compress directory to tar.gz with Commons Compress for my project.

I am able to create the .tar.gz file on the server, but I am unable to download it locally.

    ...
    File f = new File(path);
    System.out.println(f.exists());
    String entryName = base + f.getName();
    TarArchiveEntry tarEntry = new TarArchiveEntry(f, entryName);
    tOut.putArchiveEntry(tarEntry);

    if (f.isFile()) {
        IOUtils.copy(new FileInputStream(f), tOut);
        tOut.closeArchiveEntry();
    ...

Any suggestions on what can be done with tOut or after IOUtils.copy(new FileInputStream(f), tOut); to download the .tar.gz file locally. Currently its being generated in path. Thanks

0

There are 0 answers