Spark Uri错误:java.lang.IllegalArgumentException: Illegal character in opaque part at index 5

val destinationPath = "file:\\E:\\newcode\\MyFirstProject\\data\\stockresult.txt" ;
FileSystem fs = FileSystem.get(URI.create(path),conf);
writer = new BufferedWriter(new OutputStreamWriter(fs.create(new Path(path))));
if(null!=writer){
logger.info("[HdfsOperate]>> initialize writer succeed!");
}

出现了下面的错误:

Exception in thread “main” java.lang.IllegalArgumentException: Illegal character in opaque part at index 5: file:\E:\newcode\MyFirstProject\data\stockresult.txt
at java.net.URI.create(URI.java:852)

问题是Uri格式没写对,写成下面这样就对了

val destinationPath = "file:/E:/newcode/MyFirstProject/data/stockresult.txt" ;

关注公众号“大模型全栈程序员”回复“小程序”获取1000个小程序打包源码。更多免费资源在http://www.gitweixin.com/?p=2627

发表评论

邮箱地址不会被公开。 必填项已用*标注