Source

object Source

This object provides convenience methods to create an iterable representation of a source file.

Companion
class
Source
Source.scala
class Object
trait Matchable
class Any

Value members

Concrete methods

def createBufferedSource(inputStream: InputStream, bufferSize: Int, reset: () => Source, close: () => Unit)(codec: Codec): BufferedSource

Reads data from inputStream with a buffered reader, using the encoding in implicit parameter codec.

Value Params
bufferSize

buffer size (defaults to Source.DefaultBufSize)

close

a () => Unit method which closes the stream (if unset, close() will do nothing)

codec

(implicit) a scala.io.Codec specifying behavior (defaults to Codec.default)

inputStream

the input stream from which to read

reset

a () => Source which resets the stream (if unset, reset() will throw an Exception)

Returns

the buffered source

Source
Source.scala
def fromBytes(bytes: Array[Byte])(codec: Codec): Source

Create a Source from array of bytes, decoding the bytes according to codec.

Returns

the created Source instance.

Source
Source.scala
def fromBytes(bytes: Array[Byte], enc: String): Source
def fromChar(c: Char): Source

Creates a Source instance from a single character.

def fromChars(chars: Array[Char]): Source

creates Source from array of characters, with empty description.

def fromFile(name: String)(codec: Codec): BufferedSource

creates Source from file with given name, setting its description to filename.

creates Source from file with given name, using given encoding, setting its description to filename.

def fromFile(uri: URI)(codec: Codec): BufferedSource

creates source from file with given file URI.

def fromFile(uri: URI, enc: String): BufferedSource

creates Source from file with given file: URI

def fromFile(file: File)(codec: Codec): BufferedSource

creates Source from file, using default character encoding, setting its description to filename.

def fromFile(file: File, enc: String): BufferedSource

same as fromFile(file, enc, Source.DefaultBufSize)

def fromFile(file: File, enc: String, bufferSize: Int): BufferedSource
def fromFile(file: File, bufferSize: Int)(codec: Codec): BufferedSource

Creates Source from file, using given character encoding, setting its description to filename. Input is buffered in a buffer of size bufferSize.

def fromIterable(iterable: Iterable[Char]): Source

Creates a Source from an Iterable.

Value Params
iterable

the Iterable

Returns

the Source

Source
Source.scala
def fromRawBytes(bytes: Array[Byte]): Source

Create a Source from array of bytes, assuming one byte per character (ISO-8859-1 encoding.)

def fromResource(resource: String, classLoader: ClassLoader)(codec: Codec): BufferedSource

Reads data from a classpath resource, using either a context classloader (default) or a passed one.

Value Params
classLoader

classloader to be used, or context classloader if not specified

resource

name of the resource to load from the classpath

Returns

the buffered source

Source
Source.scala

creates Source from a String, with no description.

def fromURI(uri: URI)(codec: Codec): BufferedSource

creates Source from file with given file: URI

same as fromURL(new URL(s))(Codec(enc))

same as fromURL(new URL(s))

def fromURL(url: URL, enc: String): BufferedSource

same as fromInputStream(url.openStream())(Codec(enc))

def fromURL(url: URL)(codec: Codec): BufferedSource

same as fromInputStream(url.openStream())(codec)

Creates a Source from System.in.

Concrete fields