title: to replace a word from data accessed from file
body: <p>My job is to replace all the occurences of <strong>Bond</strong> with <strong>Hound</strong>. I have tried the  following code.</p>
  
  <pre><code>import java.io.BufferedReader;
  import java.io.FileNotFoundException;
  import java.io.FileReader;
  import java.io.IOException;
  import java.util.StringTokenizer;
  
  
  public class myTry {
      public static void main(String[] args)
      {
          String fileName = "C:\\Users\\KingKong\\Desktop\\WorkSpace\\Victory\\src\\test2.txt";
          FileReader f = null;
          StringTokenizer str = null;
          String temp = "";
          try {
              f = new FileReader(fileName);
          } catch (FileNotFoundException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
          }
          BufferedReader br = new BufferedReader(f);
          try {
              temp = br.readLine();
          } catch (IOException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
          }
          str = new StringTokenizer(temp);
          String token = "";
          System.out.println(str);
          while(str.hasMoreTokens())
          {
              token = str.nextToken();
              if(token.equals("Bond"))
              {
                  token.replace("Bond","Hound");
              }
          }
          String newMod = str.toString();
          System.out.println(newMod);
          System.out.println(str);
  
      }
  }
  </code></pre>
  
  <p>But it gives me the output (through the console) via the print statements as:</p>
  
  <pre><code>java.util.StringTokenizer@4d24bd93
  java.util.StringTokenizer@4d24bd93
  java.util.StringTokenizer@4d24bd93
  </code></pre>
  
  <p>What does this mean? My logic is 
   - to access the file, 
   - read the data into a string tokenizer object, 
   - check Token by Token whether there is any "Bond" in the token, 
   - if yes Change it.</p>
  
  <p>Thanks for the formatting @kgdesouz
  Moreover i dropped the ideat of using the String Tokenizer.What i wanted to do is done by the normal String Class as it is.Here is the code below</p>
  
  <pre><code>import java.io.BufferedReader;
  import java.io.FileNotFoundException;
  import java.io.FileReader;
  import java.io.IOException;
  import java.util.StringTokenizer;
  
  
  public class myTry {
      public static void main(String[] args)
      {
          String fileName = "C:\\Users\\KingKong\\Desktop\\WorkSpace\\Victory\\src\\test2.txt";
          FileReader f = null;
          StringTokenizer str = null;
          String temp = "";
          try {
              f = new FileReader(fileName);
          } catch (FileNotFoundException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
          }
          BufferedReader br = new BufferedReader(f);
          try {
              temp = br.readLine();
          } catch (IOException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
          }
          System.out.println(temp);
          String newMod = temp.replaceAll("Bond","Hound");
  
          System.out.println(newMod);
  
  
  
      }
  }
  </code></pre>
  
  <p>It gives the output </p>
  
  <pre><code>Bond is a bad boy.Bond goes to temple EveryDay.
  Hound is a bad boy.Hound goes to temple EveryDay.
  </code></pre>
  
  <p>Cheers!!</p>