au.csiro.pbdava.ssparkle.common.utils.SerialUtils.scala Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of variant-spark_2.11 Show documentation
Show all versions of variant-spark_2.11 Show documentation
Genomic variants interpretation toolkit
The newest version!
package au.csiro.pbdava.ssparkle.common.utils
import java.io.{InputStream, ObjectInputStream, ObjectOutputStream, OutputStream}
import scala.reflect.ClassTag
object SerialUtils {
def write[T](s: T, outStream: => OutputStream) {
LoanUtils.withCloseable(new ObjectOutputStream(outStream)) { out => out.writeObject(s) }
}
def read[T](inStream: => InputStream)(implicit t: ClassTag[T]): T = {
LoanUtils.withCloseable(new ObjectInputStream(inStream)) { in =>
in.readObject().asInstanceOf[T]
}
}
}