If you know the number of lines in your file and if you're randomising complete rows, you can just randomise by line number and then read that selected row. Just select a random line via the Random class and store the list of random numbers, so you don't pick one twice.
BufferedReader reader = new BufferedReader(new FileReader(new File("file.cvs")));
BufferedWriter chosen = new BufferedWriter(new FileWriter(new File("chosen.cvs")));
BufferedWriter notChosen = new BufferedWriter(new FileWriter(new File("notChosen.cvs")));
int numChosenRows = 10000;
long numLines = 1000000000;
Set<Long> chosenRows = new HashSet<Long>(numChosenRows+1, 1);
for(int i = 0; i < numChosenRows; i++) {
while(!chosenRows.add(nextLong(numLines))) {
// add returns false if the value already exists in the Set
}
}
String line;
for(long lineNo = 0; (line = reader.readLine()) != null; lineNo++){
if(chosenRows.contains(lineNo)){
// Do nothing for the moment
} else {
notChosen.write(line);
}
}
// Randomise the set of chosen rows
// Use RandomAccessFile to write the rows in that order
See this answer for the nextLong method, which produces a random long scaled to a particular size.
Edit: As most people, I overlooked the requirement for writing the randomly selected lines in a random order. I'm presuming that RandomAccessFile would help with that. Just randomise the List with the chosen rows and access them in that order. As for the unchosen ones, I edited the code above to simply ignore the chosen ones.