| 64 | } |
| 65 | |
| 66 | static void exportAll(String filename) throws IOException{ |
| 67 | Database db = DatabaseBuilder.open(new File(filename)); |
| 68 | try{ |
| 69 | for(String tableName : db.getTableNames()){ |
| 70 | String csvName = tableName + ".csv"; |
| 71 | Writer csv = new FileWriter(csvName); |
| 72 | try{ |
| 73 | System.out.println(String.format("Exporting '%s' to %s/%s", |
| 74 | tableName, System.getProperty("user.dir"), csvName)); |
| 75 | int rows = export(db, tableName, csv); |
| 76 | System.out.println(String.format("%d rows exported", rows)); |
| 77 | }finally{ |
| 78 | try{ |
| 79 | csv.flush(); |
| 80 | csv.close(); |
| 81 | }catch(IOException ex){} |
| 82 | } |
| 83 | } |
| 84 | }finally{ |
| 85 | db.close(); |
| 86 | } |
| 87 | |
| 88 | } |
| 89 | |
| 90 | static void printUsage(){ |
| 91 | System.out.println("Usage:"); |