java.lang.ArrayIndexOutOfBoundsException: 3
at CountTime$$anonfun$1.apply(CountTime.scala:13)
at CountTime$$anonfun$1.apply(CountTime.scala:11)
看别人写的这个可以读取文件夹所有文件,自己读取却提示数组越界。
val mbt=sc.textFile("/home/hadoop/Data/ ", 2).map()
改为
val mbt=sc.textFile("/home/hadoop/Data/*.log", 2)
可以读取所有文件
本地文件读取
val local_file_1 = sc.textFile("/home/hadoop/sp.txt")
val local_file_2 = sc.textFile("file://home/hadoop/sp.txt")
当前目录下的文件
val file1 = sc.textFile("sp.txt")
HDFS文件
val hdfs_file1 = sc.textFile("hdfs://192.168.146.100:9000/data/input/123.txt")
多文件读取
val file2 = sc.textFile("sp.txt,a.txt,b.txt")
全目录读取
val hdfs_file2 = sc.textFile("hdfs://192.168.146.100:9000//data/input/")
通配符匹配
val file2 = sc.textFile("file://home/hadoop/*.txt")
读取压缩文件
val file3 = sc.textFile("file://home/hadoop/sp.gz")