Java Extract Random Values from Text File -


I posted a first about extracting eight values ​​before using an external text file using Java. The text file contains the first 1000 major numbers and I have written a method to read the data from the text file.

I would like to know how to remove the eight values ​​ random and apply the results to another method.

On the lines of this:

  Read the data from the file; Select eight random numbers from the file; Random numbers apply in the method;   

I am able to remove the first eight numbers (as many are in response to my previous question), but now I am trying to remove eight random values ​​- I How can i

Thank you.

There is another way:

  from the list & lt; Long & gt; Numbers = New Arreelist & lt; Long & gt; (); // Here you create a reader with your file ((line = reader. Readline ())! = Null {number.add (long.value (number)) long} [selected] notes = new long [8] () ; Random R = new random (); (int i = 0; i & lt; selected numbers.length; i ++) {selected number [i] = numbers.get (r.nextInt (numbers.Size) ));} // 8 random numbers are the numbers in the array   

The advantage is that this is a little more effective then the answer of the ball. You can call list Course by Can team

Comments