title: scanning in and grabbing a specific token
body: <p>I am having trouble with what I have been testing for a few days now.</p>
  
  <p>All using Stacks and Queues</p>
  
  <pre><code>Sample.txt : My mom and dad both think I will do good at my gig tomorrow.
  </code></pre>
  
  <p>I have a GUI that attach's a file and parses the file for Palindromes. I want to for instance,</p>
  
  <p>I can find <code>mom</code> as a palindrome, and since <code>mom.length()</code> is == to <code>3</code> i would then grab the third token from <code>mom</code>, which in this case would be <code>both</code>. I am able to grab all of these palindromes correctly, just at a loss on how i would traverse tokens that i haven't 'read' in yet?</p>
  
  <p>my method is, </p>
  
  <pre><code>public void fileDecode() throws FileNotFoundException
      {
  
  
              while(scanInput.hasNext())
              {
                  int counter = 0;
                  int nextPalindrome = 0;
                  String token = scanInput.next();
                  Stack&lt;Character&gt; stk = new Stack&lt;Character&gt;();
                  Queue&lt;Character&gt; que = new LinkedList&lt;Character&gt;();
                  for (int i = 0; i &lt; token.length(); ++i)
                  {
                      stk.push(token.charAt(i));
                      que.add(token.charAt(i));
  
                  }
                  for (int j = 0; j &lt; token.length(); ++j)
                  {
                          char tempStk = stk.pop();
                          char tempQue = que.remove();
  
                          if (tempStk == tempQue)
                          {
                              counter++;
                          }
                  }
  
                  if (counter == token.length())
                  {
                     //build.append(token + " ");  #if i want to see the palindromes
                      nextPalindrome = token.length(); //the length/distance of the token desired
                  } 
  
              }  
          }
      }
  </code></pre>