title: Splitting and converting String to int
body: <p>I have a problem with my code. I read a couple of numbers of a text-file. For example:
  Textfile.txt</p>
  
  <pre><code>1, 21, 333
  </code></pre>
  
  <p>With my following code I want to split and convert the numbers from String to int.</p>
  
  <pre><code>int answer = 0;
  int factor = 1;
  
  // Splitting and deleting the "," AND converting String to int.
  for (String retval : line.split(",")) {
      for (int j = retval.length() - 1; j &gt;= 0; j--) {
          answer = answer + (retval.charAt(j) - '0') * factor;
          factor *= 1;
      }
      System.out.println(answer);
      answer = (answer - answer);
  }
  </code></pre>
  
  <p>I get the result in my console (int):</p>
  
  <pre><code>1 3 9
  </code></pre>
  
  <p>I see that the number 3 is a result of 2 + 1, and the number 9 is a result of 3 + 3 + 3.
  What can I do, to receive the following result in my console (int)?</p>
  
  <pre><code>1 21 333
  </code></pre>
  
  <p>/EDIT: I am only allowed to use Java.lang and Java.IO</p>