public static boolean isEmpty ( File pFile ) { if ( pFile . isDirectory ( ) ) { return ( pFile . list ( ) . length == 0 ) ; } return ( pFile . length ( ) == 0 ) ; }
Tests if a file or directory has no content . A file is empty if it has a length of 0L . A non - existing file is also considered empty . A directory is considered empty if it contains no files .