public static String getContentType(final String fileName) {

		if (Util.empty(fileName)) {
			return ConfigurationProperties.getDefaultMimeType();
		}

		String mimeType = null;

		if (fileName.lastIndexOf('.') > -1) {
			String suffix = fileName.substring(fileName.lastIndexOf('.') + 1).toLowerCase();
			mimeType = ConfigurationProperties.getFileMimeTypeForExtension(suffix);
		}

		if (mimeType == null) {
			mimeType = URLConnection.guessContentTypeFromName(fileName);
			if (mimeType == null) {
				mimeType = ConfigurationProperties.getDefaultMimeType();
			}
		}

		return mimeType;
	}
public static String getContentType ( final String fileName ) { if ( Util . empty ( fileName ) ) { return ConfigurationProperties . getDefaultMimeType ( ) ; } String mimeType = null ; if ( fileName . lastIndexOf ( '.' ) > - 1 ) { String suffix = fileName . substring ( fileName . lastIndexOf ( '.' ) + 1 ) . toLowerCase ( ) ; mimeType = ConfigurationProperties . getFileMimeTypeForExtension ( suffix ) ; } if ( mimeType == null ) { mimeType = URLConnection . guessContentTypeFromName ( fileName ) ; if ( mimeType == null ) { mimeType = ConfigurationProperties . getDefaultMimeType ( ) ; } } return mimeType ; }
Attempts to guess the content-type for the given file name.

@param fileName the file name to return the content-type for.
@return the content-type for the given fileName, or a generic type if unknown.