code: public String guessContentTypeFromFile(File file) {
          String contentType = URLConnection.guessContentTypeFromName(file.getName());
          if (contentType == null) {
              return "application/octet-stream";
          } else {
              return contentType;
          }
      }
docs: Guess Content-Type header from the given file (defaults to "application/octet-stream").
  
  @param file The given file
  @return The guessed Content-Type