aboutsummaryrefslogtreecommitdiff
path: root/JavaCSVTest.java
diff options
context:
space:
mode:
authorPaul Duncan <pabs@pablotron.org>2016-08-31 19:05:56 -0400
committerPaul Duncan <pabs@pablotron.org>2016-08-31 19:05:56 -0400
commit5339b9050a1e2bae6b8013f72e1a4e43f940290c (patch)
treec7c4a2ed52d22fc8bc36c06b17b3c5d8a5675621 /JavaCSVTest.java
parentf4e9ec22683fe87a50bab8457f0ea6ae6f91e76d (diff)
downloadcsv-test-master.tar.bz2
csv-test-master.zip
add java, refactor rubyHEADmaster
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();
+ }
+}