Source

scala.io.Source
See theSource companion class
object Source

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

Attributes

Companion
class
Graph
Supertypes
class Object
trait Matchable
class Any
Self type
Source.type

Members list

Value members

Concrete methods

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

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

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

Value parameters

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)

Attributes

Returns

the buffered source

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

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

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

Attributes

Returns

the created Source instance.

Creates a Source instance from a single character.

Creates a Source instance from a single character.

Attributes

creates Source from array of characters, with empty description.

creates Source from array of characters, with empty description.

Attributes

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

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

Attributes

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

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

Attributes

creates source from file with given file URI.

creates source from file with given file URI.

Attributes

creates Source from file with given file: URI

creates Source from file with given file: URI

Attributes

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

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

Attributes

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

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

Attributes

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

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

Attributes

Creates a Source from an Iterable.

Creates a Source from an Iterable.

Value parameters

iterable

the Iterable

Attributes

Returns

the Source

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

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

Value parameters

classLoader

classloader to be used, or context classloader if not specified

resource

name of the resource to load from the classpath

Attributes

Returns

the buffered source

creates Source from a String, with no description.

creates Source from a String, with no description.

Attributes

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

creates Source from file with given file: URI

creates Source from file with given file: URI

Attributes

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

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

Attributes

same as fromURL(new URL(s))

same as fromURL(new URL(s))

Attributes

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

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

Attributes

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

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

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

Attributes

Creates a Source from System.in.

Creates a Source from System.in.

Attributes

Deprecated methods

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

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

Attributes

Deprecated
[Since version 2.13.9] Use `fromBytes` and specify an encoding

Concrete fields