title: How to read N number of lines from a file in java randomly
body: <p>I am fairly new to java, so please bear with me if I have done something wrong. I have written a code in java that reads in N number of lines from a file in java and puts it in array of double and then prints it out;</p>
  
  <pre><code>ArrayList&lt;Double&gt; numbers = new ArrayList&lt;Double&gt;();
  Scanner read = new Scanner(new File("numberfile"));
  int counter = 0;
  while(read.hasNextLine() &amp;&amp; counter &lt; 10)
  {
      System.out.println(read);
      counter++;
  }
  </code></pre>
  
  <p>The file contains bunch of numbers from 1 to 100;</p>
  
  <p>Currently, my code prints out all the numbers like this [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], if I tell it to read the first 10 numbers. What I want to do now is print out these numbers in a random order, for example [2, 1, 6, 8, 9, 3, 7, 10, 3, 5]. </p>
  
  <p>And also if possible, I want to write a code that prints out the first 10 numbers randomly N number of times. For example, print out the first 10 numbers 50 times in a random order.</p>
  
  <p>Thanks for your help and please let me know if I am unclear.</p>