code: public static void main(String[] args) throws IOException {
      if (args.length == 0) {
        System.err.println("Usage: PosTagger [-d tagdict] [-di case_insensiteve_tagdict] model < tokenized_sentences");
        System.exit(1);
      }
      int ai=0;
      boolean test = false;
      String tagdict = null;
      boolean caseSensitive = true;
      while(ai < args.length && args[ai].startsWith("-")) {
        if (args[ai].equals("-d")) {
          tagdict = args[ai+1];
          ai+=2;
        }
        else if (args[ai].equals("-di")) {
          tagdict = args[ai+1];
          ai+=2;
          caseSensitive = false;
        }
      }
      POSTaggerME tagger;
      String model = args[ai++];
      String dictFile = null;
      if (ai < args.length) {
        dictFile = args[ai++];
      }
      
      if (tagdict != null) {
        if (dictFile != null) {
          tagger = new PosTagger(model,new Dictionary(dictFile),new POSDictionary(tagdict,caseSensitive));
        }
        else {
          tagger = new PosTagger(model,new POSDictionary(tagdict,caseSensitive));
        }
      }
      else {
        if (dictFile != null) {
          tagger = new PosTagger(model,new Dictionary(dictFile));
        }
        else {
          tagger = new PosTagger(model,(Dictionary)null);
        }
      }
      if (test) {
        System.out.println(tagger.tag(args[ai]));
      }
      else {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        
        for (String line = in.readLine(); line != null; line = in.readLine()) {
          System.out.println(tagger.tag(line));
        }
      }
    }
docs: <p>Part-of-speech tag a string passed in on the command line. For
  example:
  
  <p>java opennlp.tools.postag.EnglishPOSTaggerME -test "Mr. Smith gave a car to his son on Friday."