package ch.werner_randelshofer.activation;/*Copyright (C) 1999-99 Werner Randelshoferwerner.randelshofer@mythen.chhttp://www.mythen.ch/w.randelshofer/    Permission to use this release of URLConnectionCTD is herebygranted without fee provided that the complete copyrightnotice and this permission notice appear in all copiesand in supporting documentation.*/import java.io.*;import java.net.*;/**This content type detector usesjava.net.URLConnection#guessContentTypeFromStream()to determine the type of data.@author	Werner Randelshofer, Staldenmattweg 2, CH-6405 Immensee, Switzerland.@version	1998-06-12	Created.*/public class URLConnectionCTDimplements ContentTypeDetector	{	/**	Return the number of bytes needed to	determine the content type.	*/ 	public int getMinimalDeterminableDataLength()		{		return 10;		}	/**	Return the base MIME Type of this data. This method is	expected to ALWAYS return a valid (non-null) MIME Type.	I suggest that if the DataTypeDetector implementation cannot 	determine the type of the data, it use the convention of	returning "application/octet-stream".	@param	the first few bytes of the data file.	@return MIME Type	*/	public String getContentType(byte[] dataSnippet)		{		String contentType = null;		try	{			ByteArrayInputStream stream = new ByteArrayInputStream(dataSnippet);			contentType = URLConnection.guessContentTypeFromStream(stream);			}		catch (IOException e)			{ }		finally			{			if (contentType != null)				{ return contentType; }			else				{ return ContentTypeDetector.CONTENT_TYPE_UNKNOWN; }			}		}	}