title: Assigning the number of lines in a files.txt to the array length-java
body: <p>The program reads from a file.txt and assigns the data in the file to an array element. 
  Now I don't know how many lines the file will have, so I cant initialize the array size and I don't want to use arrayList. </p>
  
  <p>Is there a way to count the number of line in the file and assign that number to the array size? </p>
  
  <p>Example of data in the file:</p>
  
  <pre><code>    Item 2333 $283
  
      Item 2343 $363
  
      Item 2655 $243
  
      Item 2853 $223
  </code></pre>
  
  <p>After the counting the array size would be set to 4.</p>
  
  <p>Please be kind, I'm a beginner.
  Thanks in advance.</p>