if ((InputStream.class.isAssignableFrom(c)) && ("text".equals(df.getPrimaryType()))) { String encoding = availableFlavors[i].getParameter("charset"); if (encoding == null) encoding = "us-ascii"; Reader r = null; try {  r = new InputStreamReader (new ByteArrayInputStream(new byte[0]), encoding); } catch(UnsupportedEncodingException uee) {  } if (r != null) return df; } }   return(null); }
return null; }
selectBestTextFlavor(DataFlavor[] availableFlavors){  for(int i=0; i<availableFlavors.length; i++)    {      DataFlavor df = availableFlavors[i];      Class c = df.representationClass;      // A Reader or String is good.      if ((Reader.class.isAssignableFrom(c))	  || (String.class.isAssignableFrom(c)))	{	  return df;	}      // A InputStream is good if the mime primary type is "text"      if ((InputStream.class.isAssignableFrom(c))	  && ("text".equals(df.getPrimaryType())))        {          String encoding = availableFlavors[i].getParameter("charset");          if (encoding == null)            encoding = "us-ascii";          Reader r = null;          try            {              // Try to construct a dummy reader with the found encoding              r = new InputStreamReader                    (new ByteArrayInputStream(new byte[0]), encoding);            }          catch(UnsupportedEncodingException uee) { /* ignore */ }          if (r != null)            return df;        }    }  // Nothing found  return(null);}