### Question:
ReconUtils { public void untarCheckpointFile(File tarFile, Path destPath) throws IOException { FileInputStream fileInputStream = null; BufferedInputStream buffIn = null; GzipCompressorInputStream gzIn = null; try { fileInputStream = new FileInputStream(tarFile); buffIn = new BufferedInputStream(fileInputStream); gzIn = new GzipCompressorInputStream(buffIn); if (!destPath.toFile().exists()) { boolean success = destPath.toFile().mkdirs(); if (!success) { throw new IOException("Unable to create Destination directory."); } } try (TarArchiveInputStream tarInStream = new TarArchiveInputStream(gzIn)) { TarArchiveEntry entry; while ((entry = (TarArchiveEntry) tarInStream.getNextEntry()) != null) { Path path = Paths.get(destPath.toString(), entry.getName()); HddsUtils.validatePath(path, destPath); File f = path.toFile(); if (entry.isDirectory()) { boolean success = f.mkdirs(); if (!success) { LOG.error("Unable to create directory found in tar."); } } else { int count; byte[] data = new byte[WRITE_BUFFER]; FileOutputStream fos = new FileOutputStream(f); try (BufferedOutputStream dest = new BufferedOutputStream(fos, WRITE_BUFFER)) { while ((count = tarInStream.read(data, 0, WRITE_BUFFER)) != -1) { dest.write(data, 0, count); } } } } } } finally { IOUtils.closeStream(gzIn); IOUtils.closeStream(buffIn); IOUtils.closeStream(fileInputStream); } } ReconUtils(); static File getReconScmDbDir(ConfigurationSource conf); File getReconDbDir(ConfigurationSource conf, String dirConfigKey); static File createTarFile(Path sourcePath); void untarCheckpointFile(File tarFile, Path destPath); HttpURLConnection makeHttpCall(URLConnectionFactory connectionFactory,
                                  String url, boolean isSpnego); File getLastKnownDB(File reconDbDir, String fileNamePrefix); static void upsertGlobalStatsTable(Configuration sqlConfiguration,
                                            GlobalStatsDao globalStatsDao,
                                            String key,
                                            Long count);  }### Answer:
@Test public void testUntarCheckpointFile() throws Exception { File newDir = folder.newFolder(); File file1 = Paths.get(newDir.getAbsolutePath(), "file1") .toFile(); String str = "File1 Contents"; BufferedWriter writer = new BufferedWriter(new FileWriter( file1.getAbsolutePath())); writer.write(str); writer.close(); File file2 = Paths.get(newDir.getAbsolutePath(), "file2") .toFile(); str = "File2 Contents"; writer = new BufferedWriter(new FileWriter(file2.getAbsolutePath())); writer.write(str); writer.close(); File tarFile = createTarFile(newDir.toPath()); File outputDir = folder.newFolder(); new ReconUtils().untarCheckpointFile(tarFile, outputDir.toPath()); assertTrue(outputDir.isDirectory()); assertTrue(outputDir.listFiles().length == 2); }