blob: 91ee366a6353366c164ce1d42f5c0ed1450201f9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
import au.com.bytecode.opencsv.CSVReader;
import au.com.bytecode.opencsv.CSVWriter;
import java.io.FileReader;
import java.io.FileWriter;
public class JavaCSVTest {
private static String[] concat(final String a[], final String b[]) {
final String r[] = new String[a.length + b.length];
System.arraycopy(a, 0, r, 0, a.length);
System.arraycopy(b, 0, r, a.length, b.length);
return r;
}
private static final String FOO[] = { "foo", "foo" };
public static void main(String args[]) throws Exception {
final String src_path = args[0], dst_path = args[1];
final CSVReader src = new CSVReader(new FileReader(src_path));
final CSVWriter dst = new CSVWriter(new FileWriter(dst_path));
String row[];
while ((row = src.readNext()) != null)
dst.writeNext(concat(row, FOO));
dst.close();
}
}
|