code: private static boolean isORC(Path file, FileSystem fs)
        throws IOException {
      try {
        FSDataInputStream inputStream = fs.open(file);
        long size = fs.getFileStatus(file).getLen();
        byte[] buffer = new byte[Math.toIntExact(Math.min(size, EXPECTED_FOOTER_SIZE))];
        if (size < buffer.length) {
          return false;
        }
  
        inputStream.readFully(size - buffer.length, buffer);
  
        // get length of PostScript - last byte of the file
        int postScriptSize = buffer[buffer.length - 1] & 0xff;
        int magicLen = MAGIC_BUFFER.remaining();
  
        if (postScriptSize < magicLen + 1 || postScriptSize >= buffer.length) {
          return false;
        }
  
        if (!MAGIC_BUFFER.equals(ByteBuffer.wrap(buffer, buffer.length - 1 - magicLen, magicLen))) {
          // Old versions of ORC (0.11) wrote the magic to the head of the file
          byte[] headerMagic = new byte[magicLen];
          inputStream.readFully(0, headerMagic);
  
          // if it isn't there, this isn't an ORC file
          if (!MAGIC_BUFFER.equals(ByteBuffer.wrap(headerMagic))) {
            return false;
          }
        }
  
        return true;
      } catch (Exception e) {
        throw new RuntimeException("Error occured when checking the type of file:" + file);
      }
    }
docs: Determine if a file is ORC format.
  Steal ideas & code from presto/OrcReader under Apache License 2.0.