code: public String getMimetype(String fileName) {
          int lastPeriodIndex = fileName.lastIndexOf(".");
          if (lastPeriodIndex > 0 && lastPeriodIndex + 1 < fileName.length()) {
              String ext = fileName.substring(lastPeriodIndex + 1).toLowerCase();
              if (extensionToMimetypeMap.keySet().contains(ext)) {
                  String mimetype = (String) extensionToMimetypeMap.get(ext);
                  if (log.isDebugEnabled()) {
                      log.debug("Recognised extension '" + ext + "', mimetype is: '" + mimetype + "'");
                  }
                  return mimetype;
              } else {
                  if (log.isDebugEnabled()) {
                      log.debug("Extension '" + ext + "' is unrecognized in mime type listing" +
                              ", using default mime type: '" + MIMETYPE_OCTET_STREAM + "'");
                  }
              }
          } else {
              if (log.isDebugEnabled()) {
                  log.debug("File name has no extension, mime type cannot be recognised for: " + fileName);
              }
          }
          return MIMETYPE_OCTET_STREAM;
      }
docs: Determines the mimetype of a file by looking up the file's extension in
  an internal listing to find the corresponding mime type. If the file has
  no extension, or the extension is not available in the listing contained
  in this class, the default mimetype <code>application/octet-stream</code>
  is returned.
  <p>
  A file extension is one or more characters that occur after the last
  period (.) in the file's name. If a file has no extension, Guesses the
  mimetype of file data based on the file's extension.
  
  @param fileName The name of the file whose extension may match a known mimetype.
  @return The file's mimetype based on its extension, or a default value of
  <code>application/octet-stream</code> if a mime type value cannot be found.