code: public static void main(String[] args) {
      PorterStemmer s = new PorterStemmer();
  
  		// java org.itc.irst.tcc.kre.util.PorterStemmer
      for (int i = 0; i < args.length; i++) {
        try {
          InputStream in = new FileInputStream(args[i]);
          byte[] buffer = new byte[1024];
          int bufferLen, offset, ch;
  
          bufferLen = in.read(buffer);
          offset = 0;
          s.reset();
  
          while(true) {
            if (offset < bufferLen)
              ch = buffer[offset++];
            else {
              bufferLen = in.read(buffer);
              offset = 0;
              if (bufferLen < 0)
                ch = -1;
              else
                ch = buffer[offset++];
            }
  
            if (Character.isLetter((char) ch)) {
              s.add(Character.toLowerCase((char) ch));
            }
            else {
               s.stem();
               System.out.print(s.toString());
               s.reset();
               if (ch < 0)
                 break;
               else {
                 System.out.print((char) ch);
               }
             }
          }
  
          in.close();
        }
        catch (IOException e) {
          System.out.println("error reading " + args[i]);
        }
      }
    }
docs: Test program for demonstrating the Stemmer.  It reads a file and
  stems each word, writing the result to standard out.
  Usage: Stemmer file-name