public static void tar(@NotNull File source, @NotNull File dest) throws IOException {
        if (!source.exists()) {
            throw new IllegalArgumentException("No source file or folder exists: " + source.getAbsolutePath());
        }
        if (dest.exists()) {
            throw new IllegalArgumentException("Destination refers to existing file or folder: " + dest.getAbsolutePath());
        }

        try (TarArchiveOutputStream tarOut = new TarArchiveOutputStream(new GZIPOutputStream(
                new BufferedOutputStream(Files.newOutputStream(dest.toPath())), 0x1000))) {
            doTar("", source, tarOut);
        } catch (IOException e) {
            IOUtil.deleteFile(dest); // operation filed, let's remove the destination archive
            throw e;
        }
    }
@Test
    public void testFolderArchived() throws Exception {
        File src = new File(randName);
        src.mkdir();
        FileWriter fw = new FileWriter(new File(src, "1.txt"));
        fw.write("12345");
        fw.close();
        fw = new FileWriter(new File(src, "2.txt"));
        fw.write("12");
        fw.close();
        CompressBackupUtil.tar(src, dest);
        Assert.assertTrue("No destination archive created", dest.exists());
        TarArchiveInputStream tai = new TarArchiveInputStream(new GZIPInputStream(new BufferedInputStream(new FileInputStream(dest))));
        ArchiveEntry entry1 = tai.getNextEntry();
        ArchiveEntry entry2 = tai.getNextEntry();
        if (entry1.getName().compareTo(entry2.getName()) > 0) { // kinda sort them lol
            ArchiveEntry tmp = entry1;
            entry1 = entry2;
            entry2 = tmp;
        }
        Assert.assertNotNull("No entry found in destination archive", entry1);
        Assert.assertEquals("Entry has wrong size", 5, entry1.getSize());
        System.out.println(entry1.getName());
        Assert.assertEquals("Entry has wrong relative path", src.getName() + "/1.txt", entry1.getName());
        System.out.println(entry2.getName());
        Assert.assertEquals("Entry has wrong size", 2, entry2.getSize());
        Assert.assertEquals("Entry has wrong relative path", src.getName() + "/2.txt", entry2.getName());
    }