public static boolean isNetcdf(String filename) {
        boolean isnc = 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 (
            // netCDF
            (header[0] == 67) && (header[1] == 68) && (header[2] == 70)
                    && (header[3] == 1)) {
                isnc = true;
            }
            else {
                isnc = false;
            }
        }

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

        return isnc;
    }