aboutsummaryrefslogtreecommitdiff
path: root/JavaCSVTest.java
diff options
context:
space:
mode:
Diffstat (limited to 'JavaCSVTest.java')
-rw-r--r--JavaCSVTest.java29
1 files changed, 29 insertions, 0 deletions
diff --git a/JavaCSVTest.java b/JavaCSVTest.java
new file mode 100644
index 0000000..91ee366
--- /dev/null
+++ b/JavaCSVTest.java
@@ -0,0 +1,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();
+ }
+}