scalax.io.managed.WriterResource.scala Maven / Gradle / Ivy
package scalax.io
package managed
import java.io.{Writer, BufferedWriter}
/**
* A ManagedResource for accessing and using Writers. Class can be created using the [[scalax.io.Resource]] object.
*/
class WriterResource[+A <: Writer] (
opener: => A,
val context:ResourceContext = DefaultResourceContext,
closeAction: CloseAction[A] = CloseAction.Noop)
extends WriteCharsResource[A]
with ResourceOps[A, WriterResource[A]] {
self =>
override def open():OpenedResource[A] = new CloseableOpenedResource(opener,context, closeAction)
override def updateContext(newContext:ResourceContext) =
new WriterResource(opener, newContext, closeAction)
override def addCloseAction(newCloseAction: CloseAction[A]) =
new WriterResource(opener, context, newCloseAction :+ closeAction)
protected def writer = this
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy