Hi, I am trying to create a new file in HDFS and write some content into it. Here is my code snippet:
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import java.io.PrintWriter;
object App {
def main(args : Array[String]) {
val conf = new Configuration()
val fs= FileSystem.get(conf)
val output = fs.create(new Path("hdfs://quickstart.cloudera:8020/user/cloudera/sample.txt"))
val writer = new PrintWriter(output)
writer.write("Hellow World")
}
}
The file is getting created in the hdfs but the problem is I can't find the content that I was trying to write into the file sample.txt. Please tell me what is the problem.