scala 文件IO Source
2015-11-25 15:55
267 查看
Source extends
Iterator[Char]
An iterable representation of source data. It may be reset with the optional resetmethod.
Subclasses must supply the underlying iterator.
Error handling may be customized by overriding the
report method.
The current input and
position, as well as the
next character methods delegate to
the positioner.
The default positioner encodes line and column numbers in the position passed to
report. This behavior can be changed by supplying a
custom positioner.
SourceSource.scalaVersion
1.0
Linear Supertypes
Known Subclasses
Type Hierarchy
Ordering
Alphabetic
By inheritance
Inherited
Source
Iterator
TraversableOnce
GenTraversableOnce
AnyRef
Any
Implicitly
by MonadOps
by any2stringadd
by StringFormat
by Ensuring
by ArrowAssoc
by alternateImplicit
Hide All
Show all
Visibility
Public
All
Instance Constructors
new
Source()
Type Members
class
GroupedIterator[B >:
A] extends
AbstractIterator[Seq] with
Iterator[Seq[B]]
A flexible iterator for transforming an Iterator[A]into an Iterator[Seq[A]], with configurable sequence size, step, and strategy for dealing with elements which don't fit evenly.
class
LineIterator extends
AbstractIterator[String] with
Iterator[String]
class
Positioner extends
AnyRef
Concrete Value Members
def
++(that: ⇒
collection.Iterator[Char]):
collection.Iterator[Char]
[use case] Concatenates this iterator with another.def
/:[B](z:
B)(op: (B,
Char) ⇒ B):
B
Applies a binary operator to a start value and all elements of this traversable or iterator, going left to right.def
:\[B](z:
B)(op: (Char,
B) ⇒
B):
B
Applies a binary operator to all elements of this traversable or iterator and a start value, going right to left.object
NoPositioner extends
Positioner
object
RelaxedPosition extends
Position
A Position implementation which ignores errors in the positions.object
RelaxedPositioner extends
Positioner
def
addString(b:
StringBuilder):
StringBuilder
Appends all elements of this traversable or iterator to a string builder.def
addString(b:
StringBuilder, sep:
String):
StringBuilder
Appends all elements of this traversable or iterator to a string builder using a separator string.def
addString(b:
StringBuilder, start:
String, sep:
String, end:
String):
StringBuilder
Appends all elements of this traversable or iterator to a string builder using start, end, and separator strings.def
aggregate[B](z: ⇒
B)(seqop: (B,
Char) ⇒
B, combop: (B,
B) ⇒
B):
B
Aggregates the results of applying an operator to subsequent elements.def
buffered:
collection.BufferedIterator[Char]
Creates a buffered iterator from this iterator.def
ch:
Char
def
close():
Unit
The close() method closes the underlying resource.def
collect[B](pf:
PartialFunction[Char,
B]):
collection.Iterator[B]
Creates an iterator by transforming values produced by this iterator with a partial function, dropping those values for which the partial function is not defined.def
collectFirst[B](pf:
PartialFunction[Char,
B]):
Option[B]
Finds the first element of the traversable or iterator for which the given partial function is defined, and applies the partial function to it.def
contains(elem:
Any):
Boolean
Tests whether this iterator contains a given value as an element.def
copyToArray(xs:
Array[Char],
start:
Int, len:
Int):
Unit
[use case] Copies selected values produced by this iterator to an array.def
copyToArray(xs:
Array[A]):
Unit
[use case] Copies values of this traversable or iterator to an array.def
copyToArray(xs:
Array[A],
start:
Int):
Unit
[use case] Copies values of this traversable or iterator to an array.def
copyToBuffer[B >:
Char](dest:
Buffer[B]):
Unit
Copies all elements of this traversable or iterator to a buffer.def
corresponds[B](that:
GenTraversableOnce[B])(p: (Char,
B) ⇒
Boolean):
Boolean
Tests whether every element of this iterator relates to the corresponding element of another collection by satisfying a test predicate.def
count(p: (Char) ⇒
Boolean):
Int
Counts the number of elements in the traversable or iterator which satisfy a predicate.var
descr:
String
description of this source, default emptydef
drop(n:
Int):
collection.Iterator[Char]
Advances this iterator past the first n elements, or the length of the iterator, whichever is smaller.def
dropWhile(p: (Char) ⇒
Boolean):
collection.Iterator[Char]
Skips longest sequence of elements of this iterator which satisfy given predicatep, and returns an iterator of the remaining elements.
def
duplicate: (collection.Iterator[Char],
collection.Iterator[Char])
Creates two new iterators that both iterate over the same elements as this iterator (in the same order).def
exists(p: (Char) ⇒
Boolean):
Boolean
Tests whether a predicate holds for some of the values produced by this iterator.def
filter(p: (Char) ⇒
Boolean):
collection.Iterator[Char]
Returns an iterator over all the elements of this iterator that satisfy the predicatep.
def
filterNot(p: (Char) ⇒
Boolean):
collection.Iterator[Char]
Creates an iterator over all the elements of this iterator which do not satisfy a predicate p.def
find(p: (Char) ⇒
Boolean):
Option[Char]
Finds the first value produced by the iterator satisfying a predicate, if any.def
flatMap[B](f: (Char)
⇒
GenTraversableOnce[B]):
collection.Iterator[B]
Creates a new iterator by applying a function to all values produced by this iterator and concatenating the results.def
fold[A1 >:
Char](z:
A1)(op: (A1,
A1) ⇒
A1):
A1
Folds the elements of this traversable or iterator using the specified associative binary operator.def
foldLeft[B](z:
B)(op: (B,
Char) ⇒
B):
B
Applies a binary operator to a start value and all elements of this traversable or iterator, going left to right.def
foldRight[B](z:
B)(op: (Char,
B) ⇒
B):
B
Applies a binary operator to all elements of this traversable or iterator and a start value, going right to left.def
forall(p: (Char) ⇒
Boolean):
Boolean
Tests whether a predicate holds for all values produced by this iterator.def
foreach(f: (Char) ⇒
Unit):
Unit
[use case] Applies a function fto all values produced by this iterator.
def
getLines():
Iterator[String]
Returns an iterator who returns lines (NOT including newline character(s)).def
grouped[B >:
Char](size:
Int):
GroupedIterator[B]
Returns an iterator which groups this iterator into fixed size blocks.def
hasDefiniteSize:
Boolean
Tests whether this Iterator has a known size.def
hasNext:
Boolean
Returns [b]trueif this source has more characters.
def
indexOf[B >:
Char](elem:
B):
Int
Returns the index of the first occurrence of the specified object in this iterable object.def
indexWhere(p: (Char) ⇒
Boolean):
Int
Returns the index of the first produced value satisfying a predicate, or -1.def
isEmpty:
Boolean
Tests whether this iterator is empty.def
isTraversableAgain:
Boolean
Tests whether this Iterator can be repeatedly traversed.def
length:
Int
Returns the number of elements in this iterator.def
map[B](f: (Char)
⇒ B):
collection.Iterator[B]
Creates a new iterator that maps all produced values of this iterator to new values using a transformation function.def
max:
A
[use case] Finds the largest element.def
maxBy[B](f: (A) ⇒
B):
A
[use case] Finds the first element which yields the largest value measured by function f.def
min:
A
[use case] Finds the smallest element.def
minBy[B](f: (A) ⇒
B):
A
[use case] Finds the first element which yields the smallest value measured by function f.def
mkString:
String
Displays all elements of this traversable or iterator in a string.def
mkString(sep:
String):
String
Displays all elements of this traversable or iterator in a string using a separator string.def
mkString(start:
String, sep:
String, end:
String):
String
Displays all elements of this traversable or iterator in a string using start, end, and separator strings.var
nerrors:
Int
def
next():
Char
Returns next character.def
nonEmpty:
Boolean
Tests whether the traversable or iterator is not empty.var
nwarnings:
Int
def
padTo(len:
Int, elem:
Char):
collection.Iterator[Char]
[use case] Appends an element value to this iterator until a given target length is reached.def
partition(p: (Char) ⇒
Boolean): (collection.Iterator[Char],
collection.Iterator[Char])
Partitions this iterator in two iterators according to a predicate.def
patch[B >:
Char](from:
Int, patchElems:
collection.Iterator[B],
replaced:
Int):
collection.Iterator[B]
Returns this iterator with patched values.def
pos:
Int
def
product:
A
[use case] Multiplies up the elements of this collection.def
reduce[A1 >:
Char](op: (A1,
A1) ⇒
A1):
A1
Reduces the elements of this traversable or iterator using the specified associative binary operator.def
reduceLeft[B >:
Char](op: (B,
Char) ⇒
B):
B
Applies a binary operator to all elements of this traversable or iterator, going left to right.def
reduceLeftOption[B >:
Char](op: (B,
Char) ⇒
B):
Option[B]
Optionally applies a binary operator to all elements of this traversable or iterator, going left to right.def
reduceOption[A1 >:
Char](op: (A1,
A1) ⇒
A1):
Option[A1]
Reduces the elements of this traversable or iterator, if any, using the specified associative binary operator.def
reduceRight[B >:
Char](op: (Char,
B) ⇒
B):
B
Applies a binary operator to all elements of this traversable or iterator, going right to left.def
reduceRightOption[B >:
Char](op: (Char,
B) ⇒
B):
Option[B]
Optionally applies a binary operator to all elements of this traversable or iterator, going right to left.def
report(pos:
Int, msg:
String, out:
PrintStream):
Unit
def
reportError(pos:
Int, msg:
String, out:
PrintStream = Console.err):
Unit
Reports an error message to the output stream out.
def
reportWarning(pos:
Int, msg:
String, out:
PrintStream = Console.out):
Unit
defreset():
Source
The reset() method creates a fresh copy of this Source.def
sameElements(that:
collection.Iterator[_]):
Boolean
Tests if another iterator produces the same values as this one.def
scanLeft[B](z:
B)(op: (B,
Char) ⇒ B):
collection.Iterator[B]
Produces a collection containing cumulative results of applying the operator going left to right.def
scanRight[B](z:
B)(op: (Char,
B) ⇒
B):
collection.Iterator[B]
Produces a collection containing cumulative results of applying the operator going right to left.def
seq:
collection.Iterator[Char]
A version of this collection with all of the operations implemented sequentially (i.e., in a single-threaded manner).def
size:
Int
The size of this traversable or iterator.def
slice(from:
Int, until:
Int):
collection.Iterator[Char]
Creates an iterator returning an interval of the values produced by this iterator.def
sliding[B >:
Char](size:
Int, step:
Int = 1):
GroupedIterator[B]
Returns an iterator which presents a "sliding window" view of another iterator.def
span(p: (Char) ⇒
Boolean): (collection.Iterator[Char],
collection.Iterator[Char])
Splits this Iterator into a prefix/suffix pair according to a predicate.def
sum:
A
[use case] Sums up the elements of this collection.def
take(n:
Int):
collection.Iterator[Char]
Selects first n values of this iterator.def
takeWhile(p: (Char) ⇒
Boolean):
collection.Iterator[Char]
Takes longest prefix of values produced by this iterator that satisfy a predicate.def
to[Col[_]]:
Col[A]
[use case] Converts this traversable or iterator into another by copying all elements.def
toArray:
Array[A]
[use case] Converts this traversable or iterator to an array.def
toBuffer[B >:
Char]:
Buffer[B]
Uses the contents of this traversable or iterator to create a new mutable buffer.def
toIndexedSeq:
collection.immutable.IndexedSeq[Char]
Converts this traversable or iterator to an indexed sequence.def
toIterable:
collection.Iterable[Char]
Converts this traversable or iterator to an iterable collection.def
toIterator:
collection.Iterator[Char]
Returns an Iterator over the elements in this traversable or iterator.def
toList:
List[Char]
Converts this traversable or iterator to a list.def
toMap[T,
U]:
Map[T,
U]
[use case] Converts this traversable or iterator to a map.def
toSeq:
collection.Seq[Char]
Converts this traversable or iterator to a sequence.def
toSet[B >:
Char]:
Set[B]
Converts this traversable or iterator to a set.def
toStream:
collection.immutable.Stream[Char]
Converts this traversable or iterator to a stream.def
toString():
String
Converts this iterator to a string.def
toTraversable:
collection.Traversable[Char]
Converts this traversable or iterator to an unspecified Traversable.def
toVector:
Vector[Char]
Converts this traversable or iterator to a Vector.def
withClose(f: () ⇒
Unit):
Source.this.type
def
withDescription(text:
String):
Source.this.type
def
withFilter(p: (Char) ⇒
Boolean):
collection.Iterator[Char]
Creates an iterator over all the elements of this iterator that satisfy the predicatep.
def
withPositioning(pos:
Positioner):
Source.this.type
def
withPositioning(on:
Boolean):
Source.this.type
Change or disable the positioner.def
withReset(f: () ⇒
Source):
Source.this.type
def
zip[B](that:
collection.Iterator[B]):
collection.Iterator[(Char,
B)]
Creates an iterator formed from this iterator and another iterator by combining corresponding values in pairs.def
zipAll[B](that:
collection.Iterator[B],
thisElem:
Char, thatElem:
B):
collection.Iterator[(Char,
B)]
[use case] Creates an iterator formed from this iterator and another iterator by combining corresponding elements in pairs.def
zipWithIndex:
collection.Iterator[(Char,
Int)]
Creates an iterator that pairs each element produced by this iterator with its index, counting from 0.Shadowed Implicit Value Members
def
filter(p: (Char) ⇒
Boolean):
collection.TraversableOnce[Char]
def
flatMap[B](f: (Char)
⇒
GenTraversableOnce[B]):
collection.TraversableOnce[B]
def
map[B](f: (Char)
⇒ B):
collection.TraversableOnce[B]
def
withFilter(p: (Char) ⇒
Boolean):
collection.Iterator[Char]
相关文章推荐
- char与byte的区别
- Mac OS X中配置Apache
- nginx log format
- 手写CrashHandler实现UncaughtExceptionHandler拦截android异常
- mysql增加新用户和无法登陆解决方法
- 依赖倒置原则(Dependence Inversion Principle)
- iOS 上下有黑边问题解决
- zabbix监控windows某端口连接数
- 从零开始 Code Review
- LeetCode 27_Remove Element
- 计算机重命名后Oracle配置的修改
- Android开发-UI控件:为ListView,GirdView,etc...添加系统自带的下拉刷新功能
- C++primer plus第六版课后编程练习答案4.5
- 单词~o(^▽^)o
- 网页设计大赛第八天
- 【运营推广】APP运营推广超级攻略(2015新版)
- scala io操作
- [PowerShell Utils] Create a list of virtual machines based on configuration read from a CSV file in Hyper-V
- Android解析XML三种方式
- 插入到sql中的数据包含单引号(')的处理方法