public static String to_stems(String str){
	   Stemmer s = new Stemmer();
	   String ret="";
	   InputStream in = new ByteArrayInputStream( str.getBytes() );
	   char[] w = new char[501];
	   try
       { while(true)

         {  int ch = in.read();
            if (Character.isLetter((char) ch))
            {
               int j = 0;
               while(true)
               {  ch = Character.toLowerCase((char) ch);
                  w[j] = (char) ch;
                  if (j < 500) j++;
                  ch = in.read();
                  if (!Character.isLetter((char) ch))
                  {
                     /* to test add(char ch) */
                     for (int c = 0; c < j; c++) s.add(w[c]);

                     /* or, to test add(char[] w, int j) */
                     /* s.add(w, j); */

                     s.stem();
                     {  String u;

                        /* and now, to test toString() : */
                        u = s.toString();
                        ret+=u+" ";
                        /* to test getResultBuffer(), getResultLength() : */
                        /* u = new String(s.getResultBuffer(), 0, s.getResultLength()); */

                        //System.out.print(u);
                     }
                     break;
                  }
               }
            }
            if (ch < 0) break;
            //System.out.print((char)ch);
         }
       }
       catch (Exception e)
       {  System.out.println("error stemming "+e);
       }
	   return(ret);

   }