public static void checkFileOrDirectoryToBeRead ( File fileOrDir , String fileDesc ) { if ( fileOrDir == null ) throw new IllegalArgumentException ( fileDesc + " must not be null." ) ; if ( ! fileOrDir . exists ( ) ) throw new IllegalArgumentException ( fileDesc + " does not exist: " + fileOrDir . getAbsolutePath ( ) ) ; if ( ! ( fileOrDir . isDirectory ( ) || fileOrDir . isFile ( ) ) ) throw new IllegalArgumentException ( fileDesc + " must be a file or a directory: " + fileOrDir . getPath ( ) ) ; if ( fileOrDir . isDirectory ( ) ) { if ( fileOrDir . list ( ) . length == 0 ) throw new IllegalArgumentException ( fileDesc + " is an empty directory: " + fileOrDir . getPath ( ) ) ; } }
Throws if the given file is null is not a file or directory or is an empty directory .