def bufferedInput(fileName: String) = new BufferedInputStream(new FileInputStream(fileName));
def bytesAsInts(fileName:String): Iterator[Int] = {
val in = bufferedInput(fileName)
Iterator continually in.read() takeWhile (_ != -1)
}
val file = bytesAsInts("test.txt")
file foreach(_=>printf("%c",_:Int))
// AND
file foreach(_=>printf(x=>"%c",x))
// def isNull[A] = (_: A) == null
Montag, 22. Februar 2010
How to read from a BufferedInputStream in Scala
Abonnieren
Kommentare zum Post (Atom)
Keine Kommentare:
Kommentar veröffentlichen