]> source.dussan.org Git - jackcess.git/commitdiff
add ability to dump to writer
authorJames Ahlborn <jtahlborn@yahoo.com>
Thu, 21 Sep 2006 13:20:07 +0000 (13:20 +0000)
committerJames Ahlborn <jtahlborn@yahoo.com>
Thu, 21 Sep 2006 13:20:07 +0000 (13:20 +0000)
git-svn-id: https://svn.code.sf.net/p/jackcess/code/jackcess/trunk@117 f203690c-595d-4dc9-a70b-905162fa7fd2

test/src/java/com/healthmarketscience/jackcess/DatabaseTest.java

index 1a65fcf6012e196917bc7a16b8f7199c67069a41..a383b01911b07f22757c4beafa64adfe48f337ea 100644 (file)
@@ -5,6 +5,7 @@ package com.healthmarketscience.jackcess;
 import java.io.File;
 import java.io.FileNotFoundException;
 import java.io.IOException;
+import java.io.PrintWriter;
 import java.math.BigDecimal;
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -606,16 +607,29 @@ public class DatabaseTest extends TestCase {
   }
 
   static void dumpDatabase(Database mdb) throws Exception {
-    System.out.println("DATABASE:");
+    dumpDatabase(mdb, new PrintWriter(System.out, true));
+  }
+
+  static void dumpTable(Table table) throws Exception {
+    dumpTable(table, new PrintWriter(System.out, true));
+  }
+
+  static void dumpDatabase(Database mdb, PrintWriter writer) throws Exception {
+    writer.println("DATABASE:");
     for(Table table : mdb) {
-      dumpTable(table);
+      dumpTable(table, writer);
     }
   }
 
-  static void dumpTable(Table table) throws Exception {
-    System.out.println("TABLE: " + table.getName());
+  static void dumpTable(Table table, PrintWriter writer) throws Exception {
+    writer.println("TABLE: " + table.getName());
+    List<String> colNames = new ArrayList<String>();
+    for(Column col : table.getColumns()) {
+      colNames.add(col.getName());
+    }
+    writer.println("COLUMNS: " + colNames);
     for(Object row : table) {
-      System.out.println(row);
+      writer.println(row);
     }
   }