public static int identFileMagic(File file) {
        int fileId = FILEID_UNKNOWN;
        byte[] magicBytes = new byte[16];
        int magicLength;
        RandomAccessFile raf = null;
        RandomAccessFileInputStream rafin;
        ByteCountingPushBackInputStream pbin = null;
        try {
            raf = new RandomAccessFile(file, "r");
            rafin = new RandomAccessFileInputStream(raf);
            pbin = new ByteCountingPushBackInputStream(rafin, 16);
            magicLength = pbin.readFully(magicBytes);
            if (magicLength == 16) {
                if (GzipReader.isGzipped(pbin)) {
                    fileId = FILEID_GZIP;
                    // TODO check for compress arc or warc too
                } else if (ArcReaderFactory.isArcFile(pbin)) {
                    fileId = FILEID_ARC;
                }
            }
        } catch (FileNotFoundException e) {
            fileId = FILEID_ERROR;
            System.out.println("Error reading: " + file.getPath());
        } catch (IOException e) {
            fileId = FILEID_ERROR;
            e.printStackTrace();
        } finally {
            if (pbin != null) {
                try {
                    pbin.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            if (raf != null) {
                try {
                    raf.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
        return fileId;
    }