diff options
author | Geoffrey Washburn <geoffrey.washburn@epfl.ch> | 2008-04-04 12:09:06 +0000 |
---|---|---|
committer | Geoffrey Washburn <geoffrey.washburn@epfl.ch> | 2008-04-04 12:09:06 +0000 |
commit | cb9f5470c9a9dabdc334b234c9c6b6fd17237198 (patch) | |
tree | d0e48d83f2a9e916c9f682160920c621dbf457d6 /src/library/scala/io/BufferedSource.scala | |
parent | 0cda1dec3f2ec23c181b17dbb0f59299bab89430 (diff) | |
download | scala-cb9f5470c9a9dabdc334b234c9c6b6fd17237198.tar.gz scala-cb9f5470c9a9dabdc334b234c9c6b6fd17237198.tar.bz2 scala-cb9f5470c9a9dabdc334b234c9c6b6fd17237198.zip |
The great library reorg!
The standard library will now be laid out approximately like this
library/scala
/jvm/scala
/jvm/jvm1.4/scala
/jvm/jvm1.5/scala
/jvm/android/scala
/jvm/cldc/scala
/dotnet/scala
To build the standard library for a given target you start by copying
the root library/scala tree to a staging area, then move down in the
hierarchy copying the nested "scala" trees on top in the staging area.
So if you wanted to build for cldc, for example, you would do something
like the following:
rsync -avz library/scala staging/
rsync -avz library/scala/jvm/scala staging/
rsync -avz library/scala/jvm/cldc/scala staging/
The ant build files will be updated to do this for you automagically,
and there will soon be shell script to do this if you want to compile
some parts of the standard library manually.
Diffstat (limited to 'src/library/scala/io/BufferedSource.scala')
-rw-r--r-- | src/library/scala/io/BufferedSource.scala | 93 |
1 files changed, 0 insertions, 93 deletions
diff --git a/src/library/scala/io/BufferedSource.scala b/src/library/scala/io/BufferedSource.scala deleted file mode 100644 index 2fae69fb10..0000000000 --- a/src/library/scala/io/BufferedSource.scala +++ /dev/null @@ -1,93 +0,0 @@ -/* __ *\ -** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2003-2008, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** -** /____/\___/_/ |_/____/_/ | | ** -** |/ ** -\* */ - -// $Id$ - - -package scala.io - -import java.io.InputStream -import java.nio.{ByteBuffer, CharBuffer} -import java.nio.channels.{ByteChannel, Channels, ReadableByteChannel} -import java.nio.charset.{Charset, CharsetDecoder} - -object BufferedSource { - - /** same as fromInputStream(inpStream, Charset.forName(enc), buffer_size, do_reset) */ - def fromInputStream(inpStream: InputStream, enc: String, buffer_size: Int, do_reset: () => Source): BufferedSource = - fromInputStream(inpStream, Charset.forName(enc), buffer_size, do_reset) - - /** same as fromInputStream(inpStream, charSet.newDecoder(), buffer_size, do_reset) */ - def fromInputStream(inpStream: InputStream, charSet: Charset, buffer_size: Int, do_reset: () => Source): BufferedSource = - fromInputStream(inpStream, charSet.newDecoder(), buffer_size, do_reset) - - /** constructs a BufferedSource instance from an input stream, using given decoder */ - def fromInputStream(inpStream: InputStream, decoder: CharsetDecoder, buffer_size: Int, do_reset: () => Source): BufferedSource = { - val byteChannel = Channels.newChannel(inpStream) - return new BufferedSource(byteChannel, decoder) { - val buf_size = buffer_size - override def reset = do_reset() - def close { inpStream.close } - } - } -} - -/** This object provides convenience methods to create an iterable - * representation of a source file. - * - * @author Burak Emir - * @version 1.0, 19/08/2004 - */ -abstract class BufferedSource(byteChannel: ReadableByteChannel, decoder: CharsetDecoder) extends Source { - - val buf_size: Int - - def close: Unit - - val byteBuffer = ByteBuffer.allocate(buf_size) - var charBuffer = CharBuffer.allocate(buf_size) - byteBuffer.position(byteBuffer.limit()) - charBuffer.position(charBuffer.limit()) - decoder.reset() - var endOfInput = false - - def fillBuffer() = { - byteBuffer.compact() - charBuffer.position(0) - byteChannel.read(byteBuffer) match { - case -1 => - endOfInput = true; - byteBuffer.position(0) - decoder.decode(byteBuffer, charBuffer, true) - decoder.flush(charBuffer) - case num_bytes => - endOfInput = false - byteBuffer.flip() - decoder.decode(byteBuffer, charBuffer, false) - charBuffer.flip() - } - } - override val iter = new Iterator[Char] { - var buf_char = { - fillBuffer() - if (endOfInput) ' ' else charBuffer.get() - } - def hasNext = { charBuffer.remaining() > 0 || !endOfInput} - def next = { - val c = buf_char - if (charBuffer.remaining() == 0) { - fillBuffer() - } - if (!endOfInput) { - buf_char = charBuffer.get() - } - c - } - } -} - |