Class cls = Class.forName("gnu.java.net.content." + typeClass); Object obj = cls.newInstance();
char[] cArray = contentType.toCharArray(); for (int i = 0; i < cArray.length; i++) { if (cArray[i] == '/') cArray[i] = '.'; else if (! ((cArray[i] >= 'A' && cArray[i] <= 'Z') || (cArray[i] >= 'a' && cArray[i] <= 'z') || (cArray[i] >= '0' && cArray[i] <= '9'))) cArray[i] = '_'; } String contentClass = new String(cArray);
  private ContentHandler getContentHandler(String contentType)  {    // No content type so just handle it as the default.    if (contentType == null || contentType.equals(""))      return null;    ContentHandler handler = null;    // If a non-default factory has been set, use it.    if (factory != null)      handler = factory.createContentHandler(contentType);    // Then try our default class.    try      {	String typeClass = contentType.replace('/', '.');	// Deal with "Content-Type: text/html; charset=ISO-8859-1".	int parameterBegin = typeClass.indexOf(';');	if (parameterBegin >= 1)	  typeClass = typeClass.substring(0, parameterBegin);	Class cls = Class.forName("gnu.java.net.content." + typeClass);	Object obj = cls.newInstance();	if (obj instanceof ContentHandler)	  {	    handler = (ContentHandler) obj;	    return handler;	  }      }    catch (ClassNotFoundException e)      {	// Ignore.      }    catch (InstantiationException e)      {	// Ignore.      }    catch (IllegalAccessException e)      {	// Ignore.      }    return handler;  }