Wednesday, September 26, 2012
Scala-IO Core: To Resource Converters
In order to simplify integration with existing libraries, most commonly Java libraries, Scala-IO provides a JavaConverters object with implicit methods that add as*** methods (asInput, asOutput, asSeekable, etc...) to several types of objects. It is the same pattern as in the scala.collection.JavaConverters object.
These methods can be used instead of the Resource.from*** methods to provide a slightly nicer appearing code.
There is one warning. When using JavaConverters, instead of Resource.from*** for creating Input/Output/Seekable/etc... objects, the chances of falling into the trap of creating non-reusable resources or causing a resource leak is increased. See: scala-io-core-reusable-resources for more details on this.
These methods can be used instead of the Resource.from*** methods to provide a slightly nicer appearing code.
There is one warning. When using JavaConverters, instead of Resource.from*** for creating Input/Output/Seekable/etc... objects, the chances of falling into the trap of creating non-reusable resources or causing a resource leak is increased. See: scala-io-core-reusable-resources for more details on this.
posted
9/26/2012
Labels:
daily-scala,
input,
JavaConverters,
Output,
readchars,
resource,
Scala,
scala-io,
scala-io core,
seekable
Subscribe to:
Post Comments (Atom)
1 comment:
Difficulty: "compicated" ?
Reply Delete