Ejemplo n.º 1
0
 @Override
 public void store() throws MappableException, UserException {
   if (draftEntries != null) {
     entries = new CSVEntryMap[draftEntries.size()];
     int i = 0;
     for (CSVEntryMap ce : draftEntries) {
       entries[i++] = ce;
     }
     // entries = (CSVEntryMap[]) draftEntries.toArray();
   }
   if (update) {
     try {
       // Write CSV.
       if (entries != null) {
         FileWriter writer = new FileWriter(fileName);
         for (int i = 0; i < entries.length; i++) {
           CSVEntryMap e = entries[i];
           for (int j = 0; j < e.entries.length; j++) {
             writer.write(e.getEntry(new Integer(j)));
             if (j < (e.entries.length - 1)) writer.write(separator);
           }
           if (i < (entries.length - 1)) writer.write("\n");
         }
         writer.close();
       }
     } catch (IOException ioe) {
       throw new UserException(-1, ioe.getMessage());
     }
   }
 }
Ejemplo n.º 2
0
  public static void main(String[] args) throws Exception {
    Mappable csv = new CSVMap();
    ((CSVMap) csv).setSeparator(";");
    ((CSVMap) csv).setIncludeEmpty(true);
    ((CSVMap) csv).setSkipFirstRow(false);

    Binary b = new Binary(new File("C:/Temp/LedenLIJST-vertrouwelijktest.csv"));
    ((CSVMap) csv).setFileContent(b);
    Mappable[] all = ((CSVMap) csv).getEntries();
    for (int i = 0; i < all.length; i++) {
      CSVEntryMap entryMap = ((CSVEntryMap) all[i]);
      logger.info(
          "a = >"
              + entryMap.getEntry(new Integer(0))
              + "< - >"
              + entryMap.getEntry(new Integer(1))
              + "< - >"
              + entryMap.getEntry(new Integer(2))
              + "< - >"
              + entryMap.getEntry(new Integer(3))
              + "< - >"
              + entryMap.getEntry(new Integer(4))
              + "< - >"
              + entryMap.getEntry(new Integer(5))
              + "< - >"
              + entryMap.getEntry(new Integer(6))
              + "< - >"
              + entryMap.getEntry(new Integer(7))
              + "< - >"
              + entryMap.getEntry(new Integer(8))
              + "< - >"
              + entryMap.getEntry(new Integer(9))
              + "< - >"
              + entryMap.getEntry(new Integer(10))
              + "< - >"
              + entryMap.getEntry(new Integer(11))
              + "<");
    }
  }