FileUtil { public static boolean isDirExists( final String dirAbsPath ) { if ( StringUtils.isBlank( dirAbsPath ) ) { logger.warn( "In isDirExists, directory name is either null or blank." ); return false; } File file = new File( dirAbsPath ); if ( file.exists() && file.isDirectory() ) { return true; } return false; } private  FileUtil(); static boolean isFileExists( final String dirAbsPath, final String fileName ); static boolean isFileExists( final String fileAbsPath ); static boolean isDirExists( final String dirAbsPath ); static File[] findFiles( final String dirAbsPath, final String ext ); static boolean setFilesExecutable( final String dirAbsPath, final String ext ); static boolean extractArchive( final String archiveFileAbsPath, final String destDirAbsPath ); static boolean extractArchive( final File archiveFile, final File destDir ); static File[] findFiles( final String dirAbsPath, final String[] extensions, boolean recursive ); static File[] findFiles( final File dirAbsPath, final String[] extensions, boolean recursive ); static File[] findFiles( final String dirAbsPath, final String fileNamePattern, boolean recursive ); static String getFileChecksum( final String fileAbsPath, ChecksumMethod checksumMethod ); static boolean deleteDirectory( final String directory ); static boolean deleteDirectory( final File directory ); static String getTemporaryFolderPath(); static boolean deleteFile( final String filePath ); static boolean createDirectory( final String dirPath ); static String getFileBaseName( final String fileName ); static boolean unzipFile( final String zipFileAbsPath, final String outputDirAbsPath ); static boolean createOrUpdateFile( final String filePath, final String fileContent ); static boolean createOrUpdateFile( final String filePath, final String fileContent,
                                              final boolean createBackup ); static boolean createNewFile( final String fileAbsPath ); static String readFileToString( final String fileName ); static String findLatestFileByLastModified( final String directory, final String fileNamePattern,
                                                       final boolean recursive );  }
@Test public void testDirExistsWithValidDir() { String dirName = FilenameUtils.concat( tmpDir, this.getDateTimeInMillis() ); File f = new File( dirName ); if ( f.mkdir() ) { assertTrue( FileUtil.isDirExists( dirName ) ); } if ( f.exists() ) { f.delete(); } }