@Test public void testGetExtractedDirectoryName_1() throws Exception { String archiveFile = ""; String result = FileNameUtils.getExtractedDirectoryName(archiveFile); assertEquals(null, result); }
public static String getExtractedDirectoryName(String archiveFile) { String path = null; ONSFileType fileType = getFileType(archiveFile); if (fileType == ONSFileType.TAR_GZ || fileType == ONSFileType.GZ) { try { GZIPInputStream gzipInputStream = null; gzipInputStream = new GZIPInputStream(new FileInputStream( archiveFile)); TarArchiveInputStream tarInput = new TarArchiveInputStream( gzipInputStream); return tarInput.getNextTarEntry().getName(); } catch (FileNotFoundException e) { LOG.error(e.getMessage(), e); } catch (IOException e) { LOG.error(e.getMessage(), e); } } else if (fileType == ONSFileType.ZIP || fileType == ONSFileType.BIN) { ZipFile zf; try { zf = new ZipFile(archiveFile); Enumeration<? extends ZipEntry> entries = zf.entries(); return entries.nextElement().getName(); } catch (IOException e) { LOG.error(e.getMessage(), e); } } return path; }
FileNameUtils { public static String getExtractedDirectoryName(String archiveFile) { String path = null; ONSFileType fileType = getFileType(archiveFile); if (fileType == ONSFileType.TAR_GZ || fileType == ONSFileType.GZ) { try { GZIPInputStream gzipInputStream = null; gzipInputStream = new GZIPInputStream(new FileInputStream( archiveFile)); TarArchiveInputStream tarInput = new TarArchiveInputStream( gzipInputStream); return tarInput.getNextTarEntry().getName(); } catch (FileNotFoundException e) { LOG.error(e.getMessage(), e); } catch (IOException e) { LOG.error(e.getMessage(), e); } } else if (fileType == ONSFileType.ZIP || fileType == ONSFileType.BIN) { ZipFile zf; try { zf = new ZipFile(archiveFile); Enumeration<? extends ZipEntry> entries = zf.entries(); return entries.nextElement().getName(); } catch (IOException e) { LOG.error(e.getMessage(), e); } } return path; } }
FileNameUtils { public static String getExtractedDirectoryName(String archiveFile) { String path = null; ONSFileType fileType = getFileType(archiveFile); if (fileType == ONSFileType.TAR_GZ || fileType == ONSFileType.GZ) { try { GZIPInputStream gzipInputStream = null; gzipInputStream = new GZIPInputStream(new FileInputStream( archiveFile)); TarArchiveInputStream tarInput = new TarArchiveInputStream( gzipInputStream); return tarInput.getNextTarEntry().getName(); } catch (FileNotFoundException e) { LOG.error(e.getMessage(), e); } catch (IOException e) { LOG.error(e.getMessage(), e); } } else if (fileType == ONSFileType.ZIP || fileType == ONSFileType.BIN) { ZipFile zf; try { zf = new ZipFile(archiveFile); Enumeration<? extends ZipEntry> entries = zf.entries(); return entries.nextElement().getName(); } catch (IOException e) { LOG.error(e.getMessage(), e); } } return path; }  }
FileNameUtils { public static String getExtractedDirectoryName(String archiveFile) { String path = null; ONSFileType fileType = getFileType(archiveFile); if (fileType == ONSFileType.TAR_GZ || fileType == ONSFileType.GZ) { try { GZIPInputStream gzipInputStream = null; gzipInputStream = new GZIPInputStream(new FileInputStream( archiveFile)); TarArchiveInputStream tarInput = new TarArchiveInputStream( gzipInputStream); return tarInput.getNextTarEntry().getName(); } catch (FileNotFoundException e) { LOG.error(e.getMessage(), e); } catch (IOException e) { LOG.error(e.getMessage(), e); } } else if (fileType == ONSFileType.ZIP || fileType == ONSFileType.BIN) { ZipFile zf; try { zf = new ZipFile(archiveFile); Enumeration<? extends ZipEntry> entries = zf.entries(); return entries.nextElement().getName(); } catch (IOException e) { LOG.error(e.getMessage(), e); } } return path; }  static String getFileExtension(String fileName); static boolean isTarGz(String componentExtension); static boolean isZip(String componentExtension); static boolean isUnsupported(String componentExtension); static String convertToValidPath(String path); static String getName(String filename); static int indexOfLastSeparator(String filename); static String getDependencyFileName(String osName,
			String componentName); static String getInstallerFilePath(String osName,
			String componentName); static String getSciprtPath(String technology, String fileName); static String getParentFolderName(String folderPath); static ONSFileType getFileType(String fileName); static String getPathFromArchive(String archiveFile,
			String charSequence); static String getExtractedDirectoryName(String archiveFile); static String getComponentEnvFilePath(String componentName); }
FileNameUtils { public static String getExtractedDirectoryName(String archiveFile) { String path = null; ONSFileType fileType = getFileType(archiveFile); if (fileType == ONSFileType.TAR_GZ || fileType == ONSFileType.GZ) { try { GZIPInputStream gzipInputStream = null; gzipInputStream = new GZIPInputStream(new FileInputStream( archiveFile)); TarArchiveInputStream tarInput = new TarArchiveInputStream( gzipInputStream); return tarInput.getNextTarEntry().getName(); } catch (FileNotFoundException e) { LOG.error(e.getMessage(), e); } catch (IOException e) { LOG.error(e.getMessage(), e); } } else if (fileType == ONSFileType.ZIP || fileType == ONSFileType.BIN) { ZipFile zf; try { zf = new ZipFile(archiveFile); Enumeration<? extends ZipEntry> entries = zf.entries(); return entries.nextElement().getName(); } catch (IOException e) { LOG.error(e.getMessage(), e); } } return path; }  static String getFileExtension(String fileName); static boolean isTarGz(String componentExtension); static boolean isZip(String componentExtension); static boolean isUnsupported(String componentExtension); static String convertToValidPath(String path); static String getName(String filename); static int indexOfLastSeparator(String filename); static String getDependencyFileName(String osName,
			String componentName); static String getInstallerFilePath(String osName,
			String componentName); static String getSciprtPath(String technology, String fileName); static String getParentFolderName(String folderPath); static ONSFileType getFileType(String fileName); static String getPathFromArchive(String archiveFile,
			String charSequence); static String getExtractedDirectoryName(String archiveFile); static String getComponentEnvFilePath(String componentName);  }