private Collection getMimeTypes2(Collection mimeTypes, InputStream in) {

		try {
			if (mimeTypes.isEmpty() || mimeTypes.size() > 1) {
				Collection mimeTypes2 = getMimeTypesInputStream(in = new BufferedInputStream(
						in));

				if (!mimeTypes2.isEmpty()) {
					if (!mimeTypes.isEmpty()) {
						// more than one glob matched

						// Check for same mime type
						for (Iterator it = mimeTypes.iterator(); it.hasNext();) {
							String mimeType = (String) it.next();
							if (mimeTypes2.contains(mimeType)) {
								// mimeTypes = new ArrayList();
								mimeTypes.add(mimeType);
								// return mimeTypes;
							}
							// Check for mime type subtype
							for (Iterator it2 = mimeTypes2.iterator(); it2
									.hasNext();) {
								String mimeType2 = (String) it2.next();
								if (isMimeTypeSubclass(mimeType, mimeType2)) {
									// mimeTypes = new ArrayList();
									mimeTypes.add(mimeType);
									// return mimeTypes;
								}
							}
						}
					} else {
						// No globs matched but we have magic matches
						return mimeTypes2;
					}
				}
			}
		} catch (Exception e) {
			throw new MimeException(e);
		} finally {
			closeStream(in);
		}
		return mimeTypes;

	}