0
我的代码是:PrintWriter的是只考虑一个斜杠,而不是在HDFS路径双斜杠
val df = sqlContext.read
.format("com.databricks.spark.xml")
.option("rowTag", header)
.load("/input/du3_init.dat")
val dfCI2 = df.select("CI2")
dfCI2.printSchema()
val path="hdfs://nameservice/user/CI2_Schema"
new PrintWriter(path) { write(dfCI2.schema.treeString);close}
当我在火花执行,我得到
Exception in thread "main" java.io.FileNotFoundException: hdfs:/nameservice/user/CI2_Schema (No such file or directory)
at java.io.FileOutputStream.open(Native Method)
at java.io.FileOutputStream.<init>(FileOutputStream.java:221)
at java.io.FileOutputStream.<init>(FileOutputStream.java:110)
只有一个斜线的存在异常中显示的hdfs路径。如何解决这个问题?在此先感谢
'PrintWriter'不应该理解像'hdfs://'或'ftp://'那样的网络路径。它的工作与本地文件系统。而在本地文件系统路径中格式为“a/b/c”。 –