+package org.argeo.slc.example.appli;\r
+\r
+import java.io.BufferedReader;\r
+import java.io.FileReader;\r
+import java.io.FileWriter;\r
+import java.io.IOException;\r
+\r
+/** Example appli. */\r
+public class ExampleAppli {\r
+ private int skipFreq = 2;\r
+\r
+ /** Filters. */\r
+ public void filter(String[] args) {\r
+ if (args.length < 2) {\r
+ throw new RuntimeException(\r
+ "Not enough arguments. Usage: <inpuit file> <output file>");\r
+ }\r
+ String input = args[0];\r
+ String output = args[1];\r
+ if (args.length > 2) {\r
+ skipFreq = Integer.parseInt(args[2]);\r
+ }\r
+\r
+ try {\r
+ BufferedReader in = new BufferedReader(new FileReader(input));\r
+ FileWriter out = new FileWriter(output);\r
+ int count = 0;\r
+ String line;\r
+ while ((line = in.readLine()) != null) {\r
+ if (count % skipFreq != 0) {\r
+ out.write(line);\r
+ out.write("\n");\r
+ }\r
+ count++;\r
+ }\r
+ out.close();\r
+ in.close();\r
+ } catch (IOException e) {\r
+ throw new RuntimeException("Appli failed", e);\r
+ }\r
+ }\r
+\r
+ /** Sets the frequency of the lines to skip. */\r
+ public void setSkipFreq(int skipFreq) {\r
+ this.skipFreq = skipFreq;\r
+ }\r
+\r
+}\r