Skip to content

Instantly share code, notes, and snippets.

@rbobillot
Last active August 29, 2015 14:21
Show Gist options
  • Save rbobillot/ba7adefc4d1bbdf07a28 to your computer and use it in GitHub Desktop.
Save rbobillot/ba7adefc4d1bbdf07a28 to your computer and use it in GitHub Desktop.
In Scala (and Java), it is SO EASY to read any file (text, binary...)
import java.io._
object Read
{
val out = "dest"
val ext = ".out"
def main( av:Array[String] )
{
try {
val src = new FileInputStream( av(0) )
val dest = new FileOutputStream( out + ext )
val bytes = Array.ofDim[Byte]( src.available )
src.read( bytes )
src.close
dest.write( bytes )
dest.close
}
catch {
case e:Throwable => println( "Error" + e )
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment