]>
git.argeo.org Git - gpl/argeo-slc.git/blob - org.argeo.slc.example/src/main/java/org/argeo/slc/example/appli/ExampleAppli.java
1 package org
.argeo
.slc
.example
.appli
;
3 import java
.io
.BufferedReader
;
4 import java
.io
.FileReader
;
5 import java
.io
.FileWriter
;
6 import java
.io
.IOException
;
9 public class ExampleAppli
{
10 private int skipFreq
= 2;
13 public void filter(String
[] args
) {
14 if (args
.length
< 2) {
15 throw new RuntimeException(
16 "Not enough arguments. Usage: <inpuit file> <output file>");
18 String input
= args
[0];
19 String output
= args
[1];
20 if (args
.length
> 2) {
21 skipFreq
= Integer
.parseInt(args
[2]);
25 BufferedReader in
= new BufferedReader(new FileReader(input
));
26 FileWriter out
= new FileWriter(output
);
29 while ((line
= in
.readLine()) != null) {
30 if (count
% skipFreq
!= 0) {
38 } catch (IOException e
) {
39 throw new RuntimeException("Appli failed", e
);
43 /** Sets the frequency of the lines to skip. */
44 public void setSkipFreq(int skipFreq
) {
45 this.skipFreq
= skipFreq
;