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
Version
1.0, 19/08/2004
Value Summary
val DefaultBufSize : Int
val NoReset : () => Source
Method Summary
def fromBytes (bytes : Array[Byte]) : Source
Creates a Source instance from the given array of bytes, with empty description.
def fromBytes (bytes : Array[Byte], enc : java.lang.String) : Source
Creates Source from array of bytes with given encoding, with empty description.
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, enc : java.lang.String) : Source
same as fromFile(file, enc, Source.DefaultBufSize)
def fromFile (name : java.lang.String, enc : java.lang.String) : Source
creates Source from file with given name, using given encoding, setting its description to filename.
def fromFile (uri : java.net.URI) : Source
creates Source from file with given file: URI
def fromFile (file : java.io.File, enc : java.lang.String, bufferSize : Int) : Source
Creates Source from file, using given character encoding, setting its description to filename. Input is buffered in a buffer of size bufferSize.
def fromFile (file : java.io.File) : Source
creates Source from file, using default character encoding, setting its description to filename.
def fromFile (name : java.lang.String) : Source
creates Source from file with given name, setting its description to filename.
def fromFile (uri : java.net.URI, enc : java.lang.String) : Source
creates Source from file with given file: URI
def fromInputStream (is : java.io.InputStream) : Source
same as BufferedSource.fromInputStream(is, "utf-8", Source.DefaultBufSize)
def fromInputStream (is : java.io.InputStream, enc : java.lang.String) : Source
same as BufferedSource.fromInputStream(is, enc, Source.DefaultBufSize)
def fromInputStream (istream : java.io.InputStream, enc : java.lang.String, maxlen : Option[Int]) : Source
reads data from istream into a byte array, and calls fromBytes with given encoding enc. If maxlen is given, reads not more bytes than maxlen; if maxlen was not given, or was <= 0, then whole istream is read and closed afterwards.
def fromString (s : java.lang.String) : Source
creates Source from string, with empty description.
def fromURL (url : java.net.URL, enc : java.lang.String) : Source
same as fromInputStream(url.openStream(), enc)
def fromURL (s : java.lang.String) : Source
def fromURL (url : java.net.URL) : Source
def fromURL (s : java.lang.String, enc : java.lang.String) : Source
same as fromURL(new URL(s), enc)
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

val NoReset : () => Source

Method Details
def fromBytes(bytes : Array[Byte]) : Source
Creates a Source instance from the given array of bytes, with empty description.
Parameters
bytes - ...
Returns
the created Source instance.

def fromBytes(bytes : Array[Byte], enc : java.lang.String) : Source
Creates Source from array of bytes with given encoding, with empty description.
Parameters
bytes - ...
enc - ...
Returns
...

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 fromFile(name : java.lang.String) : Source
creates Source from file with given name, setting its description to filename.

def fromFile(name : java.lang.String, enc : java.lang.String) : Source
creates Source from file with given name, using given encoding, setting its description to filename.

def fromFile(uri : java.net.URI) : Source
creates Source from file with given file: URI

def fromFile(uri : java.net.URI, enc : java.lang.String) : Source
creates Source from file with given file: URI

def fromFile(file : java.io.File) : Source
creates Source from file, using default character encoding, setting its description to filename.

def fromFile(file : java.io.File, enc : java.lang.String) : Source
same as fromFile(file, enc, Source.DefaultBufSize)

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

def fromURL(s : java.lang.String) : Source
Parameters
s - ...
Returns
...
Deprecated
use fromURL(s, enc)

def fromURL(s : java.lang.String, enc : java.lang.String) : Source
same as fromURL(new URL(s), enc)

def fromURL(url : java.net.URL) : Source
Parameters
url - ...
Returns
...
Deprecated
use fromURL(url, enc)

def fromURL(url : java.net.URL, enc : java.lang.String) : Source
same as fromInputStream(url.openStream(), enc)

@deprecated

def fromInputStream(istream : java.io.InputStream, enc : java.lang.String, maxlen : Option[Int]) : Source
reads data from istream into a byte array, and calls fromBytes with given encoding enc. If maxlen is given, reads not more bytes than maxlen; if maxlen was not given, or was <= 0, then whole istream is read and closed afterwards.
Parameters
istream - the input stream from which to read
enc - the encoding to apply to the bytes
maxlen - optionally, a positive int specifying maximum number of bytes to read

def fromInputStream(is : java.io.InputStream, enc : java.lang.String) : Source
same as BufferedSource.fromInputStream(is, enc, Source.DefaultBufSize)

def fromInputStream(is : java.io.InputStream) : Source
same as BufferedSource.fromInputStream(is, "utf-8", Source.DefaultBufSize)