title: reading text file into constructor array (java)
body: <p>I have a textfile with some values. </p>
  
  <pre><code>textfile data
  
  line1row1 line1row2 55
  line2row1 line2row2 44
  line3row1 line3row2 33
  </code></pre>
  
  <p>I have a data class where i have created a contructor. the data which goes into the array, i want read from the text file. </p>
  
  <pre><code>import java.io.*; 
  import java.util.*;
  
  class Data{
      public Data(String entry1, String entry2, int entry3){}
  }   
  public class readData {
      public static void main(String[] args) throws Exception{
      BufferedReader inFile = new BufferedReader (new FileReader ("scores.txt"));
  
      Data entrydata[] = new Data[3]; //create new constructor array
      for(int i = 0; i &lt; entrydata.length; i++ ){
              entrydata[i] = inFile.readLine();
          }
      }
  }
  </code></pre>
  
  <p>I get an error on "inFile.readLine()"... Cannot Convert from String to Data(where "Data" refers to class)</p>
  
  <p>I can hardcode the data [as below] but want it to be read from the file instead</p>
  
  <pre><code>Data entrydata[] = new Data[3];
  entrydata [0] = new Data("line1row1 ", "line1row2 ", 55);
  entrydata [1] = new Data("line2row1 ", "line2row2 ", 44);
  entrydata [2] = new Data("line3row1 ", "line3row2 ", 33);
  </code></pre>
  
  <p>The reason I want to do this, is so that I can access the informatin stored in the array. </p>