package tabulate.engine.opencsv

import java.io.{Reader, Writer}

import com.opencsv._
import tabulate.engine.{ReaderEngine, WriterEngine}
import tabulate.{CsvWriter, CsvReader, DecodeResult}

import scala.collection.mutable

class OpenCsvEngine extends ReaderEngine with WriterEngine {
  override def readerFor(reader: Reader, separator: Char) = {
    val csv = new CSVReader(reader, separator)

    new CsvReader[DecodeResult[Seq[String]]] {
      var n: Array[String] = csv.readNext()
      override def hasNext = n != null
      override protected def readNext() = {
        val buffer = DecodeResult(mutable.WrappedArray.make(n))
        n = csv.readNext()
        buffer
      }
      override def close() = csv.close()
    }
  }
  override def writerFor(writer: Writer, separator: Char) = {
    val out = new CSVWriter(writer, separator)
    new CsvWriter[Seq[String]] {
      override def write(ss: Seq[String]) = {
        out.writeNext(ss.toArray)
        this
      }
      override def close() = out.close()
    }
  }
}

package tabulate.engine.opencsv

import java.io.{Reader, Writer}

import com.opencsv._
import tabulate.engine.{ReaderEngine, WriterEngine}
import tabulate.{CsvWriter, CsvReader, DecodeResult}

class OpenCsvEngine extends ReaderEngine with WriterEngine {
  override def readerFor(reader: Reader, separator: Char) = {
    val csv = new CSVReader(reader, separator)

    new CsvReader[DecodeResult[Seq[String]]] {
      var n: Array[String] = csv.readNext()
      override def hasNext = n != null
      override protected def readNext() = {
        val buffer = DecodeResult(genericWrapArray(n))
        n = csv.readNext()
        buffer
      }
      override def close() = csv.close()
    }
  }
  override def writerFor(writer: Writer, separator: Char) = {
    val out = new CSVWriter(writer, separator)
    new CsvWriter[Seq[String]] {
      override def write(ss: Seq[String]) = {
        out.writeNext(ss.toArray)
        this
      }
      override def close() = out.close()
    }
  }
}

--- 
+++ 
@@ -5,6 +5,8 @@
 import com.opencsv._
 import tabulate.engine.{ReaderEngine, WriterEngine}
 import tabulate.{CsvWriter, CsvReader, DecodeResult}
+
+import scala.collection.mutable
 
 class OpenCsvEngine extends ReaderEngine with WriterEngine {
   override def readerFor(reader: Reader, separator: Char) = {
@@ -14,7 +16,7 @@
       var n: Array[String] = csv.readNext()
       override def hasNext = n != null
       override protected def readNext() = {
-        val buffer = DecodeResult(genericWrapArray(n))
+        val buffer = DecodeResult(mutable.WrappedArray.make(n))
         n = csv.readNext()
         buffer
       }
Remove an un-needed null comparison.
