HomeBlogGuestbookLab 

JDM's Blog

온갖 테스트 결과가 기록되는 이곳은 JDM's Blog입니다. :3

스칼라 파일 읽기(read file with scala)

스칼라를 이용해 줄(line)단위로 파일을 읽는 코드입니다.

/* file reading example */
import scala.io.Source
object fileReadObj {
    def main(args: Array[String]){
        try {
            for(line <- Source.fromFile("/home/path/path.txt").getLines()){
                println(line)
            }
        } catch {
            case ex: Exception => println(ex)
        }
    }
}