code: public static String autoDetect(String absolutePath) {
          String extension = null;
  
          int index = absolutePath.lastIndexOf(".") + 1;
  
          if (index >= 0 && index <= absolutePath.length()) {
              extension = absolutePath.substring(index);
          }
  
          if (extension == null || extension.isEmpty()) {
              return APPLICATION_OCTET_STREAM;
          }
  
          String mimeType = MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension.toLowerCase());
  
          if (mimeType == null) {
              // mp4 does not always get recognized automatically
              if ("mp4".equalsIgnoreCase(extension))
                  return VIDEO_MPEG4;
  
              return APPLICATION_OCTET_STREAM;
          }
  
          return mimeType;
      }
docs: Tries to auto-detect the content type (MIME type) of a specific file.
  @param absolutePath absolute path to the file
  @return content type (MIME type) of the file, or application/octet-stream if no content
  type could be determined automatically