scalax.io

Resource

object Resource extends AnyRef

Defines several factory methods for creating instances of Resource.

Note: It is very important to try an pass a method that creates/opens the underlying resource or the actual creation code as the opener. This is important so that the resource can be used more than once. If an opened resource is passed to the factory method the resulting resource can only be used once since it closes the resource when it is closed.

Example:

   val URL = new URL("http://scala-lang.org")
   val resource: Resource[InputStream] = Resource.fromInputStream(url.openStream).buffered
Since

1.0

Linear Supertypes
AnyRef, Any
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. Hide All
  2. Show all
  1. Resource
  2. AnyRef
  3. Any
Visibility
  1. Public
  2. All

Value Members

  1. def != (arg0: AnyRef): Boolean

    Attributes
    final
    Definition Classes
    AnyRef
  2. def != (arg0: Any): Boolean

    Attributes
    final
    Definition Classes
    Any
  3. def ## (): Int

    Attributes
    final
    Definition Classes
    AnyRef → Any
  4. def == (arg0: AnyRef): Boolean

    Attributes
    final
    Definition Classes
    AnyRef
  5. def == (arg0: Any): Boolean

    Attributes
    final
    Definition Classes
    Any
  6. def asInstanceOf [T0] : T0

    Attributes
    final
    Definition Classes
    Any
  7. def clone (): AnyRef

    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws()
  8. def eq (arg0: AnyRef): Boolean

    Attributes
    final
    Definition Classes
    AnyRef
  9. def equals (arg0: Any): Boolean

    Definition Classes
    AnyRef → Any
  10. def finalize (): Unit

    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws()
  11. def fromByteChannel [A <: ByteChannel] (opener: ⇒ A): ByteChannelResource[A]

    Create an Input/Output Resource instance from a ByteChannel.

    Create an Input/Output Resource instance from a ByteChannel.

    The opener param is a by-name argument an is use to open a new stream. In other words it is important to try and pass in a function for opening the stream rather than the already opened stream so that the returned Resource can be used multiple time

    opener

    the function for opening a new ByteChannel

    returns

    a ByteChannelResource

  12. def fromClasspath (name: String): InputStreamResource[InputStream]

    Create an InputStreamResource from a resource on the classpath.

    Create an InputStreamResource from a resource on the classpath. The current threads context class loader is used to load the resource

    An exception is thrown if the resource does not exist

  13. def fromClasspath (name: String, cl: Class[_]): InputStreamResource[InputStream]

    Create an InputStreamResource from a resource on the classpath.

    Create an InputStreamResource from a resource on the classpath. The classloader from the provided class is used to resolve the resource.

    An exception is thrown if the resource does not exist

  14. def fromFile (file: String): SeekableByteChannelResource[SeekableByteChannel]

    Create a file from string then create a Seekable Resource from a File

    Create a file from string then create a Seekable Resource from a File

    file

    the file to use for constructing a Seekable Resource

    returns

    a SeekableByteChannelResource

  15. def fromFile (file: File): SeekableByteChannelResource[SeekableByteChannel]

    Creates a Seekable Resource from a File

    Creates a Seekable Resource from a File

    file

    the file to use for constructing a Seekable Resource

    returns

    a SeekableByteChannelResource

  16. def fromInputStream [A <: InputStream] (opener: ⇒ A): InputStreamResource[A]

    Create an InputStreamResource from an InputStream or subclass

    Create an InputStreamResource from an InputStream or subclass

    The opener param is a by-name argument an is use to open a new stream. In other words it is important to try and pass in a function for opening the stream rather than the already opened stream so that the returned Resource can be used multiple time

    opener

    the function for opening a new InputStream

    returns

    an InputStreamResource

  17. def fromOutputStream [A <: OutputStream] (opener: ⇒ A): OutputStreamResource[A]

    Create an Output Resource instance from an OutputStream.

    Create an Output Resource instance from an OutputStream.

    The opener param is a by-name argument an is use to open a new stream. In other words it is important to try and pass in a function for opening the stream rather than the already opened stream so that the returned Resource can be used multiple time

    opener

    the function for opening a new OutputStream

    returns

    an OutputStreamResource

  18. def fromRandomAccessFile (opener: ⇒ RandomAccessFile): SeekableByteChannelResource[SeekableFileChannel]

    Create an Input/Output/Seekable Resource instance from a RandomAccess file.

    Create an Input/Output/Seekable Resource instance from a RandomAccess file.

    The opener param is a by-name argument an is use to open a new stream. In other words it is important to try and pass in a function for opening the stream rather than the already opened stream so that the returned Resource can be used multiple time

    opener

    the function for opening a new SeekableByteChannel

    returns

    a SeekableByteChannelResource

  19. def fromReadableByteChannel [A <: ReadableByteChannel] (opener: ⇒ A): ReadableByteChannelResource[A]

    Create an Input Resource instance from an ReadableByteChannel.

    Create an Input Resource instance from an ReadableByteChannel.

    The opener param is a by-name argument an is use to open a new stream. In other words it is important to try and pass in a function for opening the stream rather than the already opened stream so that the returned Resource can be used multiple time

    opener

    the function for opening a new ReadableByteChannel

    returns

    an ReadableByteChannelResource

  20. def fromReader [A <: Reader] (opener: ⇒ A): ReaderResource[A]

    Create an ReadChars Resource instance from an Reader.

    Create an ReadChars Resource instance from an Reader.

    The opener param is a by-name argument an is use to open a new stream. In other words it is important to try and pass in a function for opening the stream rather than the already opened stream so that the returned Resource can be used multiple time

    opener

    the function for opening a new Reader

    returns

    an ReaderResource

  21. def fromSeekableByteChannel [A <: SeekableByteChannel] (opener: (Seq[OpenOption]) ⇒ A): SeekableByteChannelResource[A]

  22. def fromSeekableByteChannel [A <: SeekableByteChannel] (opener: ⇒ A): SeekableByteChannelResource[A]

    Create an Input/Output/Seekable Resource instance from a SeekableByteChannel.

    Create an Input/Output/Seekable Resource instance from a SeekableByteChannel.

    The opener param is a by-name argument an is use to open a new stream. In other words it is important to try and pass in a function for opening the stream rather than the already opened stream so that the returned Resource can be used multiple time

    opener

    the function for opening a new SeekableByteChannel

    returns

    a SeekableByteChannelResource

  23. def fromURL (url: String): InputStreamResource[InputStream]

    Converts the string to a URL and creates an Input Resource from the URL

    Converts the string to a URL and creates an Input Resource from the URL

    url

    the url string to use for constructing a InputStreamResource

    returns

    an InputStreamResource

  24. def fromURL (url: URL): InputStreamResource[InputStream]

    Creates an Input Resource from a URL

    Creates an Input Resource from a URL

    url

    the url to use for constructing a InputStreamResource

    returns

    an InputStreamResource

  25. def fromWritableByteChannel [A <: WritableByteChannel] (opener: ⇒ A): WritableByteChannelResource[A]

    Create an Output Resource instance from an WritableByteChannel.

    Create an Output Resource instance from an WritableByteChannel.

    The opener param is a by-name argument an is use to open a new stream. In other words it is important to try and pass in a function for opening the stream rather than the already opened stream so that the returned Resource can be used multiple time

    opener

    the function for opening a new WritableByteChannel

    returns

    an WritableByteChannelResource

  26. def fromWriter [A <: Writer] (opener: ⇒ A): WriterResource[A]

    Create an WriteChars Resource instance with conversion traits from an Writer.

    Create an WriteChars Resource instance with conversion traits from an Writer.

    The opener param is a by-name argument an is use to open a new stream. In other words it is important to try and pass in a function for opening the stream rather than the already opened stream so that the returned Resource can be used multiple time

    opener

    the function for opening a new Writer

    returns

    an WriterResource

  27. def getClass (): java.lang.Class[_]

    Attributes
    final
    Definition Classes
    AnyRef → Any
  28. def hashCode (): Int

    Definition Classes
    AnyRef → Any
  29. def isInstanceOf [T0] : Boolean

    Attributes
    final
    Definition Classes
    Any
  30. def ne (arg0: AnyRef): Boolean

    Attributes
    final
    Definition Classes
    AnyRef
  31. def notify (): Unit

    Attributes
    final
    Definition Classes
    AnyRef
  32. def notifyAll (): Unit

    Attributes
    final
    Definition Classes
    AnyRef
  33. def synchronized [T0] (arg0: ⇒ T0): T0

    Attributes
    final
    Definition Classes
    AnyRef
  34. def toString (): String

    Definition Classes
    AnyRef → Any
  35. def wait (): Unit

    Attributes
    final
    Definition Classes
    AnyRef
    Annotations
    @throws()
  36. def wait (arg0: Long, arg1: Int): Unit

    Attributes
    final
    Definition Classes
    AnyRef
    Annotations
    @throws()
  37. def wait (arg0: Long): Unit

    Attributes
    final
    Definition Classes
    AnyRef
    Annotations
    @throws()

Inherited from AnyRef

Inherited from Any