public static boolean isHDF4(String filename) {
        boolean ish4 = false;
        RandomAccessFile raf = null;

        try {
            raf = new RandomAccessFile(filename, "r");
        }
        catch (Exception ex) {
            raf = null;
        }

        if (raf == null) {
            return false;
        }

        byte[] header = new byte[4];
        try {
            raf.read(header);
        }
        catch (Exception ex) {
            header = null;
        }

        if (header != null) {
            if (
            // HDF4
            ((header[0] == 14) && (header[1] == 3) && (header[2] == 19) && (header[3] == 1))
            /*
             * // netCDF || (header[0]==67 && header[1]==68 && header[2]==70 &&
             * header[3]==1)
             */
            ) {
                ish4 = true;
            }
            else {
                ish4 = false;
            }
        }

        try {
            raf.close();
        }
        catch (Exception ex) {
        }

        return ish4;
    }