summaryrefslogtreecommitdiff
path: root/examples/scala-js/javalib/src/main/scala/java/io/OutputStream.scala
blob: 729e69bd063ff7c7ab230e57619ebb628312e820 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
package java.io

abstract class OutputStream extends Object with Closeable with Flushable {
  def write(b: Int): Unit

  def write(b: Array[Byte]): Unit =
    write(b, 0, b.length)

  def write(b: Array[Byte], off: Int, len: Int): Unit = {
    if (off < 0 || len < 0 || len > b.length - off)
      throw new IndexOutOfBoundsException()

    var n = off
    val stop = off + len
    while (n < stop) {
      write(b(n))
      n += 1
    }
  }

  def flush(): Unit = ()

  def close(): Unit = ()

}