java version 1.8, spark version 2.11
I want to read some data from the directory ./data
in my spark project:
val sparkConf = new SparkConf().setMaster("local").setAppName("WordCount")
val sc = new SparkContext(sparkConf)
val lines = sc.textFile("datas") // datas is a dictionary which contain some txt file
it comes error:
Error while running command to get file permissions : java.io.IOException: (null) entry in command string
that says I have no permissions to read the file in directory ./datas
.
But when I change code to read a specific document in ./datas
:
val lines = sc.textFile("datas/1.txt")
it works.
How can I read all file in ./datas
using sc.textFile("datas")
?