WordStreamIterator不在java.lang下,这样一定出错。他好像连jdk里都没有。可能是自己做的类。

解决方案 »

  1.   

    Java API document 没有提供搜索功能,有没有带搜索功能的API document察看工具?例如我想察看WordStreamIterator是不是java的类
      

  2.   

    JBUILDER有这样的功能,我用的是JB7,如果引入了一个当前不可见的类,JB会有提示,点提示以后JB会去搜索所有的J2SE API和当前classpath里所有的包,如果找到以后它会自己帮你写入程序里 import xxx.xxx.xxx;这样的。WordStreamIterator不是在标准的J2SE API里,应该是教材自己提供的。
      

  3.   

    JBUILDER里有find definition的功能可以找定义。java的类是比较规矩的。按照惯例,WordStreamIterator这样的名字,应该是Iterator的subclass或subinterface。查查Iterator文档,看看有没有这个东西,一般就知道了。
      

  4.   

    WordStreamIterator是sl-275定义的,在labfile\mod09\examples有的,如下:import java.util.Iterator;
    import java.io.InputStreamReader;
    import java.io.BufferedReader;
    import java.io.IOException;/**
     * This class presents an iterator over words in an input stream.
     * A "word" is defined as any contiguous sequence of letters (including
     * an apostrope for possesive words).  All whitespace and punctuation
     * is removed.
     */
    public class WordStreamIterator implements Iterator {
      private static char    APOSTROPHE = '\'';
      private BufferedReader input;
      private String         current_line;
      private int            current_index;
      private String         next_word = null;  /**
       * This is the basic constructor.
       */
      public WordStreamIterator(InputStreamReader stream) {
        input = new BufferedReader(stream);
        // Prime the word pump
        nextLine();
        nextWord();
      }  /**
       * This method determines whether or not there are any more words.
       */
      public boolean hasNext() {
        return (next_word != null);
      }  /**
       * This method return the "next word" in the stream.
       *
       * The "next word" is already available (an may be null), but this
       * method must move forward in the stream to get the next, next word.
       */
      public Object next() {
        String result = next_word;    nextWord();    return result;
      }  /**
       * The <TT>remove</TT> method is not supported.
       */
      public void remove() {
        throw new UnsupportedOperationException();
      }  /**
       * This private method is used to read the next line in the
       * input stream.
       *
       * <TT>current_line</TT> will be <TT>null</TT> when we reach the EOF.
       */
      private void nextLine() {
        try {
          current_line = input.readLine();
          if ( current_line == null ) {
    input.close();
          }
          current_index = 0;
        } catch (IOException e) {
          current_line = null;
        }
      }  /**
       * This private method is used to parse the next word in the
       * input stream.
       *
       * This is the work-horse of this class.  It moves the current_index
       * through the current_line until it finds the start of a word, it
       * then parses the word (storing the letters in a buffer) until it
       * reaches the end of the word (a non-letter character or EOL).
       *
       * <TT>next_word</TT> will be <TT>null</TT> when we reach the EOF.
       */
      private void nextWord() {
        final StringBuffer buffer = new StringBuffer();
        char ch;
        buffer.setLength(0);    // parse over all non-letters, handling line breaks and EOF
        do {
          if ( current_line == null ) {
    // quit loop on EOF
    break;
          }      if ( current_index >= current_line.length() ) {
    // if at the end of the current line,
    // read a new one and continue from the top (could be EOF)
    nextLine();
    continue;
          }      if ( ! Character.isLetter(current_line.charAt(current_index)) ) {
    // skip over all non-letters
    current_index++;
          } else {
    // quit loop, when a letter is reached
    break;
          }
        } while ( true );    // parse letters into the buffer
        do {
          if ( current_line == null ) {
    // quit loop on EOF
    break;
          }      // get the next character
          ch = current_line.charAt(current_index);
          if ( ! Character.isLetter(ch) && (ch != APOSTROPHE) ) {
    // quit loop, when a non-letter is reached
    break;
          }      // store the character and move to the index forward
          buffer.append(ch);
          current_index++;      // if we have reached the end of line,
          // then get the next line
          // and quit the loop (EOL always means the end of a word)
          if ( current_index >= current_line.length() ) {
    nextLine();
    break;
          }
        } while ( true );    // create the next word, if any
        if ( buffer.length() == 0 ) {
          next_word = null;
        } else {
          next_word = buffer.toString();
        }
      }
    }
      

  5.   

    csdn当给分刷新页面时出错,给分没有成功怎么不能重来??