title: convert String to Array in Java
body: <p>I have a txt file like this:</p>
  
  <p>5<br>
  1<br>
  3<br>
  6<br>
  9</p>
  
  <p>I want to read them using java and store all of the numbers into a array.How do I do that? read them in as string and convert to arrray? (how to convert?)
  the file only contain ints.</p>
  
  <p>I tried read them into a string
  and use this to convert</p>
  
  <pre><code> static public int[] strToA(String str)
  {
      int len = str.length();
      int[] array = new int[len];
      for (int i = 0; i &lt; len; i++)
      {
          array[i] = Integer.parseInt(str.substring(i,i+1));
      }
      return array;
  }
  </code></pre>