예제 #1
0
 /** close. */
 public void close() {
   try {
     csvr.close();
   } catch (Exception e) {
     throw new RuntimeException(e.getMessage());
   }
 }
예제 #2
0
 /** {@inheritDoc} */
 public void write(Object obj) {
   if (null == csvr) {
     if (null == csvFormat) {
       this.csvr = new CsvWriter(new OutputStreamWriter(outputStream));
     } else {
       this.csvr = new CsvWriter(new OutputStreamWriter(outputStream), csvFormat);
     }
   }
   if (null == obj) return;
   try {
     if (obj.getClass().isArray()) {
       Object[] values = (Object[]) obj;
       String[] strValues = new String[values.length];
       for (int i = 0; i < values.length; i++) {
         strValues[i] = (null == values[i]) ? "" : values[i].toString();
       }
       csvr.write(strValues);
     } else {
       csvr.write(new String[] {obj.toString()});
     }
   } catch (Exception e) {
     throw new RuntimeException(e.getMessage());
   }
 }