All Downloads are FREE. Search and download functionalities are using the official Maven repository.

au.csiro.pbdava.ssparkle.common.utils.CSVUtils.scala Maven / Gradle / Ivy

The newest version!
package au.csiro.pbdava.ssparkle.common.utils

import com.github.tototoshi.csv.CSVWriter
import java.io.InputStream
import java.io.OutputStream
import com.github.tototoshi.csv.DefaultCSVFormat
import java.io.File

object CSVUtils {

  implicit object MyFormat extends DefaultCSVFormat {
    override val lineTerminator: String = System.lineSeparator()
  }

  def withStream(os: OutputStream)(func: CSVWriter => Unit) {
    LoanUtils.withCloseable(CSVWriter.open(os))(func)
  }

  def withPath(path: String)(func: CSVWriter => Unit) {
    LoanUtils.withCloseable(CSVWriter.open(path))(func)
  }

  def withFile(file: File)(func: CSVWriter => Unit) {
    LoanUtils.withCloseable(CSVWriter.open(file))(func)
  }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy