static void unTarUsingJava(File inFile, File untarDir,
      boolean gzipped) throws IOException {
    InputStream inputStream = null;
    TarArchiveInputStream tis = null;
    try {
      if (gzipped) {
        inputStream =
            new GZIPInputStream(Files.newInputStream(inFile.toPath()));
      } else {
        inputStream = Files.newInputStream(inFile.toPath());
      }

      inputStream = new BufferedInputStream(inputStream);

      tis = new TarArchiveInputStream(inputStream);

      for (TarArchiveEntry entry = tis.getNextTarEntry(); entry != null;) {
        unpackEntries(tis, entry, untarDir);
        entry = tis.getNextTarEntry();
      }
    } finally {
      IOUtils.cleanupWithLogger(LOG, tis, inputStream);
    }
  }
@Test(timeout = 8000)
  public void testCreateSymbolicLinkUsingJava() throws IOException {
    final File simpleTar = new File(del, FILE);
    OutputStream os = new FileOutputStream(simpleTar);
    try (TarArchiveOutputStream tos = new TarArchiveOutputStream(os)) {
      // Files to tar
      final String tmpDir = "tmp/test";
      File tmpDir1 = new File(tmpDir, "dir1/");
      File tmpDir2 = new File(tmpDir, "dir2/");
      Verify.mkdirs(tmpDir1);
      Verify.mkdirs(tmpDir2);

      java.nio.file.Path symLink = Paths.get(tmpDir1.getPath(), "sl");

      // Create Symbolic Link
      Files.createSymbolicLink(symLink, Paths.get(tmpDir2.getPath()));
      assertTrue(Files.isSymbolicLink(symLink.toAbsolutePath()));
      // Put entries in tar file
      putEntriesInTar(tos, tmpDir1.getParentFile());
      tos.close();

      File untarFile = new File(tmpDir, "2");
      // Untar using Java
      FileUtil.unTarUsingJava(simpleTar, untarFile, false);

      // Check symbolic link and other directories are there in untar file
      assertTrue(Files.exists(untarFile.toPath()));
      assertTrue(Files.exists(Paths.get(untarFile.getPath(), tmpDir)));
      assertTrue(Files.isSymbolicLink(Paths.get(untarFile.getPath(), symLink.toString())));
    } finally {
      FileUtils.deleteDirectory(new File("tmp"));
    }
  }