scala.io

object Source

[source: scala/io/Source.scala]

object Source
extends AnyRef
This object provides convenience methods to create an iterable representation of a source file.
Author
Burak Emir, Paul Phillips
Version
1.0, 19/08/2004
Value Summary
val DefaultBufSize : Int
Method Summary
def fromBytes (bytes : Array[Byte])(implicit codec : Codec) : Source
Create a Source from array of bytes, decoding the bytes according to codec.
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 (file : java.io.File, bufferSize : Int)(implicit codec : Codec) : Source
Creates Source from file, using given character encoding, setting its description to filename. Input is buffered in a buffer of size bufferSize.
def fromInputStream (inputStream : java.io.InputStream, bufferSize : Int, reset : () => Source, close : () => Unit)(implicit codec : Codec) : Source
Reads data from inputStream with a buffered reader, using encoding in implicit parameter codec.
def fromIterable (iterable : Iterable[Char]) : Source
Creates a Source from an Iterable.
def fromPath (name : java.lang.String)(implicit codec : Codec) : Source
creates Source from file with given name, setting its description to filename.
def fromRawBytes (bytes : Array[Byte]) : Source
Create a Source from array of bytes, assuming one byte per character (ISO-8859-1 encoding.)
def fromString (s : java.lang.String) : Source
creates Source from string, with empty description.
def fromURI (uri : java.net.URI)(implicit codec : Codec) : Source
creates Source from file with given file: URI
def fromURL (url : java.net.URL)(implicit codec : Codec) : Source
same as fromInputStream(url.openStream())(codec)
def stdin : Source
Creates a Source from System.in.
Methods inherited from AnyRef
getClass, hashCode, equals, clone, toString, notify, notifyAll, wait, wait, wait, finalize, ==, !=, eq, ne, synchronized
Methods inherited from Any
==, !=, isInstanceOf, asInstanceOf
Value Details
val DefaultBufSize : Int

Method Details
def stdin : Source
Creates a Source from System.in.

def fromIterable(iterable : Iterable[Char]) : Source
Creates a Source from an Iterable.
Parameters
iterable - the Iterable
Returns
the Source instance.

def fromChar(c : Char) : Source
Creates a Source instance from a single character.
Parameters
c - ...
Returns
the create Source instance.

def fromChars(chars : Array[Char]) : Source
creates Source from array of characters, with empty description.
Parameters
chars - ...
Returns
...

def fromString(s : java.lang.String) : Source
creates Source from string, with empty description.
Parameters
s - ...
Returns
...

def fromBytes(bytes : Array[Byte])(implicit codec : Codec) : Source
Create a Source from array of bytes, decoding the bytes according to codec.
Parameters
bytes - ...
enc - ...
Returns
the created Source instance.

def fromRawBytes(bytes : Array[Byte]) : Source
Create a Source from array of bytes, assuming one byte per character (ISO-8859-1 encoding.)

def fromPath(name : java.lang.String)(implicit codec : Codec) : Source
creates Source from file with given name, setting its description to filename.

def fromURI(uri : java.net.URI)(implicit codec : Codec) : Source
creates Source from file with given file: URI

def fromURL(url : java.net.URL)(implicit codec : Codec) : Source
same as fromInputStream(url.openStream())(codec)

def fromFile(file : java.io.File, bufferSize : Int)(implicit codec : Codec) : Source
Creates Source from file, using given character encoding, setting its description to filename. Input is buffered in a buffer of size bufferSize.

def fromInputStream(inputStream : java.io.InputStream, bufferSize : Int, reset : () => Source, close : () => Unit)(implicit codec : Codec) : Source
Reads data from inputStream with a buffered reader, using encoding in implicit parameter codec.
Parameters
inputStream - the input stream from which to read
bufferSize - buffer size (defaults to Source.DefaultBufSize)
reset - a () => Source which resets the stream (if unset, reset() will throw an Exception)
codec - (implicit) a scala.io.Codec specifying behavior (defaults to Codec.default)
Returns
the buffered source