Last active
August 29, 2015 14:21
-
-
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...)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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