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」。 –