LoginSignup
2
2

More than 5 years have passed since last update.

scala で hdfs 上のファイルを読み込む

Posted at

メモ

scala で hdfs 上のファイルを読み込む


import org.apache.hadoop.conf.Configuration
import org.apache.hadoop.fs.FileSystem
import org.apache.hadoop.fs.FileStatus
import org.apache.hadoop.fs.Path

val conf = new Configuration()
val hdfs = FileSystem.get(conf)

val is : InputStream = hdfs.open(new Path("test.txt"))
val br = new BufferedReader(new InputStreamReader(is))

val it = Iterator.continually(br.readLine()).takeWhile(_ != null).toList
  for(line <- it) {
    println(line)
  }
}
br.close
2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2