Java : add integers using StringTokenizer
<p>I want to read the data from an "DataFile.txt" file, but in a program I have 2 integers, so how can I pass integers ("days" and "tprice" variables are supposed to be integers) using StringTokenizer?</p>

<pre><code> private void readDataFileAndDisplay()
      {    
           String allRecord="";     // all details of customer    
           try
           {
                Scanner in = new Scanner (new FileReader ("DataFile.txt")); //open file    
                String myEntry = "" ;   
                String name ="";
                String ID="";
                String roomType ="";
                String meal="";
                String days="";
                String tprice="";  

                while (in.hasNextLine ())
                {    
                    myEntry = in.nextLine();
                    StringTokenizer st = new StringTokenizer (myEntry, ",");
                    while (st.hasMoreTokens ())
                    {    
                        name = st.nextToken();
                        ID = st.nextToken();
                        name = st.nextToken();
                        roomType = st.nextToken();
                        meal = st.nextToken();
                        days = st.nextToken();
                        tprice =st.nextToken();
                        myList.add (new Customer (name, ID, roomType, meal, days, tprice));
                    }    
                } // end of while loop
                in.close(); // close file
              } catch (IOException ex)
              {
                     System.out.println ("file loading failed.");
              }
   }
</code></pre>

<p>I have also tried parseInt like:</p>

<pre><code>int Intdays = Integer.parseInt (st.nextToken ());
int IntTprice = Integer.parseInt (st.nextToken ());
</code></pre>

<p>but after compiling it is showing the exception below:
<img src="http://i.stack.imgur.com/XxKRl.jpg" alt="enter image description here"></p>
