title: stanford nlp tokenizer
body: <p>How can i tokenize a string in java class using stanford parser? </p>
  
  <p>I am only able to find examples of documentProcessor and PTBTokenizer taking text from external file.</p>
  
  <pre><code> DocumentPreprocessor dp = new DocumentPreprocessor("hello.txt");
     for (List sentence : dp) {
      System.out.println(sentence);
    }
    // option #2: By token
  
     PTBTokenizer ptbt = new PTBTokenizer(new FileReader("hello.txt"),
            new CoreLabelTokenFactory(), "");
    for (CoreLabel label; ptbt.hasNext(); ) {
      label = (CoreLabel) ptbt.next();
      System.out.println(label);
    }
  </code></pre>
  
  <p>Thanks.</p>