title: how to exclude checking words in quotations using java
body: <p>It's the first time I'm doing this so I didn't want to be lengthy. I'm building a cross reference from reading a java program. I'm to exclude java keywords, commented words and words in quotations. I got through with excluding the java keywords and the commented words but I'm having problems excluding those in quotes.</p>
  
  <pre><code>public class CrossReference {
  static Scanner in;
  static PrintWriter out;
  static int currentLine = 0;
  
  public static void main(String[] args) throws IOException {
      in  = new Scanner (new FileReader("keywords.txt"));
      out = new PrintWriter (new FileWriter("crossreference.out"));
      LinkedList keywords = new LinkedList();
      while (in.hasNextLine()) {
          String word = in.nextLine();
          keywords.addTail(new NodeData(word));
      }
      in  = new Scanner (new FileReader("program.txt"));
      BinaryTree bst = new BinaryTree();
      while(in.hasNextLine()){
          String line = in.nextLine();
          out.printf("%3d. %s\n", ++currentLine,line);
          getWordsOnLine(line,bst,keywords);
      }
      out.printf("\nWords                LineNumber\n\n");
      bst.inOrder();
      out.close();
  }
  
  public static void getWordsOnLine(String inputLine, BinaryTree bst, LinkedList keywords){
      Scanner inLine = new Scanner(inputLine);
      inLine.useDelimiter("[^a-zA-Z//\"*]+");
      boolean b = true;
      while(inLine.hasNext() &amp;&amp; b){
          String word = inLine.next().toLowerCase();
          if (word.contains("/") || word.contains("\"") || word.contains("*")) {
              b = false;
          } //this works for the commented words but not so well for the ones in quotes as it also excludes words after those in quotes
          else {
              boolean key = false;
              Node curr = keywords.head;
              while (curr != null) {
                  if (curr.data.str.equals(word)) key = true;
                  curr = curr.next;
              }
              if (key == false) {
                  TreeNode node = bst.findOrInsert(new TreeNodeData(word));
                  ListNode p = new ListNode(currentLine);
                  p.next = node.data.firstLine;
                  node.data.firstLine = p;
              }
          }  
      }    
  }   
  </code></pre>
  
  <p>}</p>