Code example for RandomAccessFile

Methods: readFully, seek, skipBytes

0
 
    @Override 
    public boolean canHandle(RandomAccessFile raf, File file) throws IOException {
        boolean canHandle = false;
         
        raf.seek(0);
        byte[] riffHeader = new byte[4];
        raf.readFully(riffHeader);
        if (new String(riffHeader).equals("RIFF")) {
            raf.skipBytes(4);
            byte[] aviType = new byte[4];
            raf.readFully(aviType);
            if (new String(aviType).equals("AVI ")) {
                canHandle = true;
            } 
        } 
        if (canHandle) {
            if (logger.isLoggable(Level.FINE)) {
                logger.fine("Can handle " + raf);
            } 
        } else {