scala 文件IO Source

Source extends Iterator[Char]

An iterable representation of source data. It may be reset with the optional reset method.

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.

Source
Source.scala
Version

1.0

Linear Supertypes
Known Subclasses
Type Hierarchy
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. Source
  2. Iterator
  3. TraversableOnce
  4. GenTraversableOnce
  5. AnyRef
  6. Any
Implicitly
  1. by MonadOps
  2. by any2stringadd
  3. by StringFormat
  4. by Ensuring
  5. by ArrowAssoc
  6. by alternateImplicit
  1. Hide All
  2. Show all
Visibility
  1. Public
  2. All

Instance Constructors

  1. new Source()

Type Members

  1. class GroupedIterator[B >: A] extends AbstractIterator[Seq[B]] 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.

  2. class LineIterator extends AbstractIterator[String] with Iterator[String]
  3. class Positioner extends AnyRef

Concrete Value Members

  1. def ++(that: ⇒ collection.Iterator[Char]): collection.Iterator[Char]

    [use case] Concatenates this iterator with another.

  2. 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.

  3. 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.

  4. object NoPositioner extends Positioner
  5. object RelaxedPosition extends Position

    A Position implementation which ignores errors in the positions.

  6. object RelaxedPositioner extends Positioner
  7. def addString(b: StringBuilder): StringBuilder

    Appends all elements of this traversable or iterator to a string builder.

  8. def addString(b: StringBuilder, sep: String): StringBuilder

    Appends all elements of this traversable or iterator to a string builder using a separator string.

  9. 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.

  10. def aggregate[B](z: ⇒ B)(seqop: (B, Char) ⇒ B, combop: (B, B) ⇒ B): B

    Aggregates the results of applying an operator to subsequent elements.

  11. def buffered: collection.BufferedIterator[Char]

    Creates a buffered iterator from this iterator.

  12. def ch: Char
  13. def close(): Unit

    The close() method closes the underlying resource.

  14. 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.

  15. 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.

  16. def contains(elem: Any): Boolean

    Tests whether this iterator contains a given value as an element.

  17. def copyToArray(xs: Array[Char], start: Int, len: Int): Unit

    [use case] Copies selected values produced by this iterator to an array.

  18. def copyToArray(xs: Array[A]): Unit

    [use case] Copies values of this traversable or iterator to an array.

  19. def copyToArray(xs: Array[A], start: Int): Unit

    [use case] Copies values of this traversable or iterator to an array.

  20. def copyToBuffer[B >: Char](dest: Buffer[B]): Unit

    Copies all elements of this traversable or iterator to a buffer.

  21. 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.

  22. def count(p: (Char) ⇒ Boolean): Int

    Counts the number of elements in the traversable or iterator which satisfy a predicate.

  23. var descr: String

    description of this source, default empty

  24. def drop(n: Int): collection.Iterator[Char]

    Advances this iterator past the first n elements, or the length of the iterator, whichever is smaller.

  25. def dropWhile(p: (Char) ⇒ Boolean): collection.Iterator[Char]

    Skips longest sequence of elements of this iterator which satisfy given predicate p, and returns an iterator of the remaining elements.

  26. 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).

  27. def exists(p: (Char) ⇒ Boolean): Boolean

    Tests whether a predicate holds for some of the values produced by this iterator.

  28. def filter(p: (Char) ⇒ Boolean): collection.Iterator[Char]

    Returns an iterator over all the elements of this iterator that satisfy the predicate p.

  29. 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.

  30. def find(p: (Char) ⇒ Boolean): Option[Char]

    Finds the first value produced by the iterator satisfying a predicate, if any.

  31. 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.

  32. 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.

  33. 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.

  34. 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.

  35. def forall(p: (Char) ⇒ Boolean): Boolean

    Tests whether a predicate holds for all values produced by this iterator.

  36. def foreach(f: (Char) ⇒ Unit): Unit

    [use case] Applies a function f to all values produced by this iterator.

  37. def getLines(): Iterator[String]

    Returns an iterator who returns lines (NOT including newline character(s)).

  38. def grouped[B >: Char](size: Int): GroupedIterator[B]

    Returns an iterator which groups this iterator into fixed size blocks.

  39. def hasDefiniteSize: Boolean

    Tests whether this Iterator has a known size.

  40. def hasNext: Boolean

    Returns true if this source has more characters.

  41. def indexOf[B >: Char](elem: B): Int

    Returns the index of the first occurrence of the specified object in this iterable object.

  42. def indexWhere(p: (Char) ⇒ Boolean): Int

    Returns the index of the first produced value satisfying a predicate, or -1.

  43. def isEmpty: Boolean

    Tests whether this iterator is empty.

  44. def isTraversableAgain: Boolean

    Tests whether this Iterator can be repeatedly traversed.

  45. def length: Int

    Returns the number of elements in this iterator.

  46. 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.

  47. def max: A

    [use case] Finds the largest element.

  48. def maxBy[B](f: (A) ⇒ B): A

    [use case] Finds the first element which yields the largest value measured by function f.

  49. def min: A

    [use case] Finds the smallest element.

  50. def minBy[B](f: (A) ⇒ B): A

    [use case] Finds the first element which yields the smallest value measured by function f.

  51. def mkString: String

    Displays all elements of this traversable or iterator in a string.

  52. def mkString(sep: String): String

    Displays all elements of this traversable or iterator in a string using a separator string.

  53. 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.

  54. var nerrors: Int
  55. def next(): Char

    Returns next character.

  56. def nonEmpty: Boolean

    Tests whether the traversable or iterator is not empty.

  57. var nwarnings: Int
  58. 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.

  59. def partition(p: (Char) ⇒ Boolean): (collection.Iterator[Char], collection.Iterator[Char])

    Partitions this iterator in two iterators according to a predicate.

  60. def patch[B >: Char](from: Int, patchElems: collection.Iterator[B], replaced: Int): collection.Iterator[B]

    Returns this iterator with patched values.

  61. def pos: Int
  62. def product: A

    [use case] Multiplies up the elements of this collection.

  63. def reduce[A1 >: Char](op: (A1, A1) ⇒ A1): A1

    Reduces the elements of this traversable or iterator using the specified associative binary operator.

  64. 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.

  65. 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.

  66. 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.

  67. 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.

  68. 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.

  69. def report(pos: Int, msg: String, out: PrintStream): Unit
  70. def reportError(pos: Int, msg: String, out: PrintStream = Console.err): Unit

    Reports an error message to the output stream out.

  71. def reportWarning(pos: Int, msg: String, out: PrintStream = Console.out): Unit
  72. def reset(): Source

    The reset() method creates a fresh copy of this Source.

  73. def sameElements(that: collection.Iterator[_]): Boolean

    Tests if another iterator produces the same values as this one.

  74. 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.

  75. 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.

  76. def seq: collection.Iterator[Char]

    A version of this collection with all of the operations implemented sequentially (i.e., in a single-threaded manner).

  77. def size: Int

    The size of this traversable or iterator.

  78. def slice(from: Int, until: Int): collection.Iterator[Char]

    Creates an iterator returning an interval of the values produced by this iterator.

  79. def sliding[B >: Char](size: Int, step: Int = 1): GroupedIterator[B]

    Returns an iterator which presents a "sliding window" view of another iterator.

  80. def span(p: (Char) ⇒ Boolean): (collection.Iterator[Char], collection.Iterator[Char])

    Splits this Iterator into a prefix/suffix pair according to a predicate.

  81. def sum: A

    [use case] Sums up the elements of this collection.

  82. def take(n: Int): collection.Iterator[Char]

    Selects first n values of this iterator.

  83. def takeWhile(p: (Char) ⇒ Boolean): collection.Iterator[Char]

    Takes longest prefix of values produced by this iterator that satisfy a predicate.

  84. def to[Col[_]]: Col[A]

    [use case] Converts this traversable or iterator into another by copying all elements.

  85. def toArray: Array[A]

    [use case] Converts this traversable or iterator to an array.

  86. def toBuffer[B >: Char]: Buffer[B]

    Uses the contents of this traversable or iterator to create a new mutable buffer.

  87. def toIndexedSeq: collection.immutable.IndexedSeq[Char]

    Converts this traversable or iterator to an indexed sequence.

  88. def toIterable: collection.Iterable[Char]

    Converts this traversable or iterator to an iterable collection.

  89. def toIterator: collection.Iterator[Char]

    Returns an Iterator over the elements in this traversable or iterator.

  90. def toList: List[Char]

    Converts this traversable or iterator to a list.

  91. def toMap[T, U]: Map[T, U]

    [use case] Converts this traversable or iterator to a map.

  92. def toSeq: collection.Seq[Char]

    Converts this traversable or iterator to a sequence.

  93. def toSet[B >: Char]: Set[B]

    Converts this traversable or iterator to a set.

  94. def toStream: collection.immutable.Stream[Char]

    Converts this traversable or iterator to a stream.

  95. def toString(): String

    Converts this iterator to a string.

  96. def toTraversable: collection.Traversable[Char]

    Converts this traversable or iterator to an unspecified Traversable.

  97. def toVector: Vector[Char]

    Converts this traversable or iterator to a Vector.

  98. def withClose(f: () ⇒ Unit): Source.this.type
  99. def withDescription(text: String): Source.this.type
  100. def withFilter(p: (Char) ⇒ Boolean): collection.Iterator[Char]

    Creates an iterator over all the elements of this iterator that satisfy the predicate p.

  101. def withPositioning(pos: Positioner): Source.this.type
  102. def withPositioning(on: Boolean): Source.this.type

    Change or disable the positioner.

  103. def withReset(f: () ⇒ Source): Source.this.type
  104. 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.

  105. 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.

  106. 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

  1. def filter(p: (Char) ⇒ Boolean): collection.TraversableOnce[Char]
  2. def flatMap[B](f: (Char) ⇒ GenTraversableOnce[B]): collection.TraversableOnce[B]
  3. def map[B](f: (Char) ⇒ B): collection.TraversableOnce[B]
  4. def withFilter(p: (Char) ⇒ Boolean): collection.Iterator[Char]
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值