@@ -0,0 +1,1429 @@
+package uk.org.cinquin.mutinack.misc_util;%0A%0Aimport java.io.FileNotFoundException;%0Aimport java.io.IOException;%0Aimport java.util.Scanner;%0A%0Apublic class LineSampler %7B%0A%0A%09public static void main(String%5B%5D args) throws FileNotFoundException, IOException %7B%0A%09%09/*try(FileReader fr = new FileReader(new File(args%5B0%5D));%0A%09%09%09%09BufferedReader br = new BufferedReader(fr);%0A%09%09%09%09Stream%3CString%3E lines = br.lines()) %7B%0A%09%09%09lines.forEach(action);*/%0A%09%09final long interval = Long.valueOf(args%5B0%5D);%0A%09%09final long chunkLength = Long.valueOf(args%5B1%5D);%0A%0A%09%09long timeSinceLast = 0;%0A%0A%09%09long leftToPrintInCurrentChunk = 0;%0A%09%09long nextChunkStart = 0;%0A%09%09long currentLine = 0;%0A%09%09@SuppressWarnings(%22resource%22)%0A%09%09final Scanner input = new Scanner(System.in);%0A%09%09while (input.hasNextLine()) %7B%0A%09%09%09final String line = input.nextLine();%0A%09%09%09final long currentTime = System.currentTimeMillis();%0A%09%09%09if (((interval %3E 0) && currentLine == nextChunkStart) %7C%7C ((interval %3C 0) && currentTime %3E (timeSinceLast + (-interval) * 1_000))) %7B%0A%09%09%09%09leftToPrintInCurrentChunk = chunkLength;%0A%09%09%09%09if (interval %3C 0) %7B%0A%09%09%09%09%09timeSinceLast = currentTime;%0A%09%09%09%09%7D else%0A%09%09%09%09%09nextChunkStart += interval;%0A%09%09%09%09System.out.println(%22Line %22 + currentLine + %22:%22);%0A%09%09%09%7D%0A%09%09%09if (leftToPrintInCurrentChunk %3E 0) %7B%0A%09%09%09%09System.out.println(line);%0A%09%09%09%09leftToPrintInCurrentChunk--;%0A%09%09%09%09if (leftToPrintInCurrentChunk == 0) %7B%0A%09%09%09%09%09System.out.println(%22-----------------------------%22);%0A%09%09%09%09%7D%0A%09%09%09%7D%0A%09%09%09currentLine++;%0A%09%09%7D%0A%09%7D%0A%7D%0A

Add new LineSampler utility.