score:19

Accepted answer

Have a look at this this example here. I think the problem is that you don't configure the default file system using

conf.set("fs.defaultFS", "hdfs://quickstart.cloudera:8020")

and pass the relative path, like so:

fs.create(new Path("/tmp/mySample.txt"))

to write to the file, call 'write' directly on the output stream returned by fs.create, like so:

val os = fs.create(new Path("/tmp/mySample.txt"))
os.write("This is a test".getBytes)

Related Query

More Query from same tag